#include <G4RunMessenger.hh>
Inheritance diagram for G4RunMessenger:
Public Member Functions | |
G4RunMessenger (G4RunManager *runMgr) | |
~G4RunMessenger () | |
void | SetNewValue (G4UIcommand *command, G4String newValues) |
G4String | GetCurrentValue (G4UIcommand *command) |
Definition at line 68 of file G4RunMessenger.hh.
G4RunMessenger::G4RunMessenger | ( | G4RunManager * | runMgr | ) |
Definition at line 47 of file G4RunMessenger.cc.
References G4UIcommand::AvailableForStates(), G4State_EventProc, G4State_GeomClosed, G4State_Idle, G4State_PreInit, G4UIcmdWithABool::SetDefaultValue(), G4UIcmdWithAString::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIparameter::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIcmdWithABool::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), G4UIparameter::SetParameterRange(), and G4UIcommand::SetRange().
00048 :runManager(runMgr) 00049 { 00050 runDirectory = new G4UIdirectory("/run/"); 00051 runDirectory->SetGuidance("Run control commands."); 00052 00053 initCmd = new G4UIcmdWithoutParameter("/run/initialize",this); 00054 initCmd->SetGuidance("Initialize G4 kernel."); 00055 initCmd->AvailableForStates(G4State_PreInit,G4State_Idle), 00056 00057 beamOnCmd = new G4UIcommand("/run/beamOn",this); 00058 beamOnCmd->SetGuidance("Start a Run."); 00059 beamOnCmd->SetGuidance("If G4 kernel is not initialized, it will be initialized."); 00060 beamOnCmd->SetGuidance("Default number of events to be processed is 1."); 00061 beamOnCmd->SetGuidance("The second and third arguments can be used for"); 00062 beamOnCmd->SetGuidance("executing a macro file at the end of each event."); 00063 beamOnCmd->SetGuidance("If the second argument, i.e. name of the macro"); 00064 beamOnCmd->SetGuidance("file, is given but the third argument is not,"); 00065 beamOnCmd->SetGuidance("the macro file will be executed for all of the"); 00066 beamOnCmd->SetGuidance("event."); 00067 beamOnCmd->SetGuidance("If the third argument (nSelect) is given, the"); 00068 beamOnCmd->SetGuidance("macro file will be executed only for the first"); 00069 beamOnCmd->SetGuidance("nSelect events."); 00070 beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00071 G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true); 00072 p1->SetDefaultValue(1); 00073 p1->SetParameterRange("numberOfEvent >= 0"); 00074 beamOnCmd->SetParameter(p1); 00075 G4UIparameter* p2 = new G4UIparameter("macroFile",'s',true); 00076 p2->SetDefaultValue("***NULL***"); 00077 beamOnCmd->SetParameter(p2); 00078 G4UIparameter* p3 = new G4UIparameter("nSelect",'i',true); 00079 p3->SetDefaultValue(-1); 00080 p3->SetParameterRange("nSelect>=-1"); 00081 beamOnCmd->SetParameter(p3); 00082 00083 verboseCmd = new G4UIcmdWithAnInteger("/run/verbose",this); 00084 verboseCmd->SetGuidance("Set the Verbose level of G4RunManager."); 00085 verboseCmd->SetGuidance(" 0 : Silent (default)"); 00086 verboseCmd->SetGuidance(" 1 : Display main topics"); 00087 verboseCmd->SetGuidance(" 2 : Display main topics and run summary"); 00088 verboseCmd->SetParameterName("level",true); 00089 verboseCmd->SetDefaultValue(0); 00090 verboseCmd->SetRange("level >=0 && level <=2"); 00091 00092 dumpRegCmd = new G4UIcmdWithAString("/run/dumpRegion",this); 00093 dumpRegCmd->SetGuidance("Dump region information."); 00094 dumpRegCmd->SetGuidance("In case name of a region is not given, all regions will be displayed."); 00095 dumpRegCmd->SetParameterName("regionName", true); 00096 dumpRegCmd->SetDefaultValue("**ALL**"); 00097 dumpRegCmd->AvailableForStates(G4State_Idle); 00098 00099 dumpCoupleCmd = new G4UIcmdWithoutParameter("/run/dumpCouples",this); 00100 dumpCoupleCmd->SetGuidance("Dump material-cuts-couple information."); 00101 dumpCoupleCmd->SetGuidance("Note that material-cuts-couple information is updated"); 00102 dumpCoupleCmd->SetGuidance("after BeamOn has started."); 00103 dumpCoupleCmd->AvailableForStates(G4State_Idle); 00104 00105 optCmd = new G4UIcmdWithABool("/run/optimizeGeometry",this); 00106 optCmd->SetGuidance("Set the optimization flag for geometry."); 00107 optCmd->SetGuidance("If it is set to TRUE, G4GeometryManager will optimize"); 00108 optCmd->SetGuidance("the geometry definitions."); 00109 optCmd->SetGuidance("GEANT4 is initialized with this flag as TRUE."); 00110 optCmd->SetParameterName("optimizeFlag",true); 00111 optCmd->SetDefaultValue(true); 00112 optCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00113 00114 brkBoECmd = new G4UIcmdWithABool("/run/breakAtBeginOfEvent",this); 00115 brkBoECmd->SetGuidance("Set a break point at the begining of every event."); 00116 brkBoECmd->SetParameterName("flag",true); 00117 brkBoECmd->SetDefaultValue(true); 00118 00119 brkEoECmd = new G4UIcmdWithABool("/run/breakAtEndOfEvent",this); 00120 brkEoECmd->SetGuidance("Set a break point at the end of every event."); 00121 brkEoECmd->SetParameterName("flag",true); 00122 brkEoECmd->SetDefaultValue(true); 00123 00124 abortCmd = new G4UIcmdWithABool("/run/abort",this); 00125 abortCmd->SetGuidance("Abort current run processing."); 00126 abortCmd->SetGuidance("If softAbort is false (default), currently processing event will be immediately aborted,"); 00127 abortCmd->SetGuidance("while softAbort is true, abortion occurs after processing the current event."); 00128 abortCmd->AvailableForStates(G4State_GeomClosed,G4State_EventProc); 00129 abortCmd->SetParameterName("softAbort",true); 00130 abortCmd->SetDefaultValue(false); 00131 00132 abortEventCmd = new G4UIcmdWithoutParameter("/run/abortCurrentEvent",this); 00133 abortEventCmd->SetGuidance("Abort currently processing event."); 00134 abortEventCmd->AvailableForStates(G4State_EventProc); 00135 00136 geomCmd = new G4UIcmdWithoutParameter("/run/geometryModified",this); 00137 geomCmd->SetGuidance("Force geometry to be closed again."); 00138 geomCmd->SetGuidance("This command must be applied"); 00139 geomCmd->SetGuidance(" if geometry has been modified after the"); 00140 geomCmd->SetGuidance(" first initialization (or BeamOn)."); 00141 geomCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00142 00143 physCmd = new G4UIcmdWithoutParameter("/run/physicsModified",this); 00144 physCmd->SetGuidance("Force all physics tables recalculated again."); 00145 physCmd->SetGuidance("This command must be applied"); 00146 physCmd->SetGuidance(" if physics process has been modified after the"); 00147 physCmd->SetGuidance(" first initialization (or BeamOn)."); 00148 physCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00149 00150 cutCmd = new G4UIcmdWithoutParameter("/run/cutoffModified",this); 00151 cutCmd->SetGuidance("/run/cutoffModified becomes obsolete."); 00152 cutCmd->SetGuidance("It is safe to remove invoking this command."); 00153 00154 constScoreCmd = new G4UIcmdWithoutParameter("/run/constructScoringWorlds",this); 00155 constScoreCmd->SetGuidance("Constrct scoring parallel world(s) if defined."); 00156 constScoreCmd->SetGuidance("This command is not mandatory, but automatically called when a run starts."); 00157 constScoreCmd->SetGuidance("But the user may use this to visualize the scoring world(s) before a run to start."); 00158 constScoreCmd->AvailableForStates(G4State_Idle); 00159 00160 materialScanner = new G4MaterialScanner(); 00161 00162 randomDirectory = new G4UIdirectory("/random/"); 00163 randomDirectory->SetGuidance("Random number status control commands."); 00164 00165 seedCmd = new G4UIcmdWithAString("/random/setSeeds",this); 00166 seedCmd->SetGuidance("Initialize the random number generator with integer seed stream."); 00167 seedCmd->SetGuidance("Number of integers should be more than 1."); 00168 seedCmd->SetGuidance("Actual number of integers to be used depends on the individual random number engine."); 00169 seedCmd->SetParameterName("IntArray",false); 00170 seedCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); 00171 00172 randDirCmd = new G4UIcmdWithAString("/random/setDirectoryName",this); 00173 randDirCmd->SetGuidance("Define the directory name of the rndm status files."); 00174 randDirCmd->SetGuidance("Directory will be created if it does not exist."); 00175 randDirCmd->SetParameterName("fileName",true); 00176 randDirCmd->SetDefaultValue("./"); 00177 randDirCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); 00178 00179 savingFlagCmd = new G4UIcmdWithABool("/random/setSavingFlag",this); 00180 savingFlagCmd->SetGuidance("The randomNumberStatus will be saved at :"); 00181 savingFlagCmd->SetGuidance("begining of run (currentRun.rndm) and " 00182 "begining of event (currentEvent.rndm) "); 00183 savingFlagCmd->SetParameterName("flag",true); 00184 savingFlagCmd->SetDefaultValue(true); 00185 00186 saveThisRunCmd = new G4UIcmdWithoutParameter("/random/saveThisRun",this); 00187 saveThisRunCmd->SetGuidance("copy currentRun.rndm to runXXX.rndm"); 00188 saveThisRunCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00189 00190 saveThisEventCmd = new G4UIcmdWithoutParameter("/random/saveThisEvent",this); 00191 saveThisEventCmd->SetGuidance("copy currentEvent.rndm to runXXXevtYYY.rndm"); 00192 saveThisEventCmd->AvailableForStates(G4State_EventProc); 00193 00194 restoreRandCmd = new G4UIcmdWithAString("/random/resetEngineFrom",this); 00195 restoreRandCmd->SetGuidance("Reset the status of the rndm engine from a file."); 00196 restoreRandCmd->SetGuidance("See CLHEP manual for detail."); 00197 restoreRandCmd->SetGuidance("The engine status must be stored beforehand."); 00198 restoreRandCmd->SetGuidance("Directory of the status file should be set by" 00199 " /random/setDirectoryName."); 00200 restoreRandCmd->SetParameterName("fileName",true); 00201 restoreRandCmd->SetDefaultValue("currentRun.rndm"); 00202 restoreRandCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); 00203 00204 randEvtCmd = new G4UIcmdWithAnInteger("/run/storeRndmStatToEvent",this); 00205 randEvtCmd->SetGuidance("Flag to store rndm status to G4Event object."); 00206 randEvtCmd->SetGuidance(" flag = 0 : not store (default)"); 00207 randEvtCmd->SetGuidance(" flag = 1 : status before primary particle generation is stored"); 00208 randEvtCmd->SetGuidance(" flag = 2 : status before event processing (after primary particle generation) is stored"); 00209 randEvtCmd->SetGuidance(" flag = 3 : both are stored"); 00210 randEvtCmd->SetGuidance("Note: Some performance overhead may be seen by storing rndm status, in particular"); 00211 randEvtCmd->SetGuidance("for the case of simplest geometry and small number of tracks per event."); 00212 randEvtCmd->SetParameterName("flag",true); 00213 randEvtCmd->SetDefaultValue(0); 00214 randEvtCmd->SetRange("flag>=0 && flag<3"); 00215 randEvtCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 00216 00217 //old commands for the rndm engine status handling 00218 // 00219 randDirOld = new G4UIcmdWithAString("/run/randomNumberStatusDirectory",this); 00220 randDirOld->SetGuidance("Define the directory name of the rndm status files."); 00221 randDirOld->SetGuidance("Directory must be creates before storing the files."); 00222 randDirOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory"); 00223 randDirOld->SetParameterName("fileName",true); 00224 randDirOld->SetDefaultValue("./"); 00225 randDirOld->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); 00226 00227 storeRandOld = new G4UIcmdWithAnInteger("/run/storeRandomNumberStatus",this); 00228 storeRandOld->SetGuidance("The randomNumberStatus will be saved at :"); 00229 storeRandOld->SetGuidance("begining of run (currentRun.rndm) and " 00230 "begining of event (currentEvent.rndm) "); 00231 storeRandOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory"); 00232 storeRandOld->SetParameterName("flag",true); 00233 storeRandOld->SetDefaultValue(1); 00234 00235 restoreRandOld = new G4UIcmdWithAString("/run/restoreRandomNumberStatus",this); 00236 restoreRandOld->SetGuidance("Reset the status of the rndm engine from a file."); 00237 restoreRandOld->SetGuidance("See CLHEP manual for detail."); 00238 restoreRandOld->SetGuidance("The engine status must be stored beforehand."); 00239 restoreRandOld->SetGuidance("Directory of the status file should be set by" 00240 " /random/setDirectoryName."); 00241 restoreRandOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory"); 00242 restoreRandOld->SetParameterName("fileName",true); 00243 restoreRandOld->SetDefaultValue("currentRun.rndm"); 00244 restoreRandOld->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); 00245 }
G4RunMessenger::~G4RunMessenger | ( | ) |
Definition at line 247 of file G4RunMessenger.cc.
00248 { 00249 delete materialScanner; 00250 delete beamOnCmd; 00251 delete verboseCmd; 00252 delete optCmd; 00253 delete dumpRegCmd; 00254 delete dumpCoupleCmd; 00255 delete brkBoECmd; 00256 delete brkEoECmd; 00257 delete abortCmd; 00258 delete abortEventCmd; 00259 delete initCmd; 00260 delete geomCmd; 00261 delete physCmd; 00262 delete cutCmd; 00263 delete randEvtCmd; 00264 delete randDirOld; delete storeRandOld; delete restoreRandOld; 00265 delete constScoreCmd; 00266 delete runDirectory; 00267 00268 delete randDirCmd; 00269 delete seedCmd; 00270 delete savingFlagCmd; 00271 delete saveThisRunCmd; 00272 delete saveThisEventCmd; 00273 delete restoreRandCmd; 00274 delete randomDirectory; 00275 }
G4String G4RunMessenger::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 375 of file G4RunMessenger.cc.
References G4UIcommand::ConvertToString(), G4RunManager::GetFlagRandomNumberStatusToG4Event(), G4RunManager::GetRandomNumberStoreDir(), and G4RunManager::GetVerboseLevel().
00376 { 00377 G4String cv; 00378 00379 if( command==verboseCmd ) 00380 { cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel()); } 00381 else if( command==randDirCmd ) 00382 { cv = runManager->GetRandomNumberStoreDir(); } 00383 else if( command==randEvtCmd ) 00384 { cv = randEvtCmd->ConvertToString(runManager->GetFlagRandomNumberStatusToG4Event()); } 00385 00386 return cv; 00387 }
void G4RunMessenger::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValues | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 277 of file G4RunMessenger.cc.
References G4RunManager::AbortEvent(), G4RunManager::AbortRun(), G4RunManager::BeamOn(), G4RunManager::ConstructScoringWorlds(), G4RunManager::CutOffHasBeenModified(), G4ProductionCutsTable::DumpCouples(), G4RunManager::DumpRegion(), G4cerr, G4cout, G4endl, G4RunManager::GeometryHasBeenModified(), G4UIcmdWithABool::GetNewBoolValue(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ProductionCutsTable::GetProductionCutsTable(), G4UImanager::GetUIpointer(), G4RunManager::Initialize(), G4RunManager::PhysicsHasBeenModified(), G4RunManager::RestoreRandomNumberStatus(), G4RunManager::rndmSaveThisEvent(), G4RunManager::rndmSaveThisRun(), G4RunManager::SetGeometryToBeOptimized(), G4UImanager::SetPauseAtBeginOfEvent(), G4UImanager::SetPauseAtEndOfEvent(), G4RunManager::SetRandomNumberStore(), G4RunManager::SetRandomNumberStoreDir(), G4RunManager::SetVerboseLevel(), G4UImessenger::StoI(), and G4RunManager::StoreRandomNumberStatusToG4Event().
00278 { 00279 if( command==beamOnCmd ) 00280 { 00281 G4int nev; 00282 G4int nst; 00283 const char* nv = (const char*)newValue; 00284 std::istringstream is(nv); 00285 is >> nev >> macroFileName >> nst; 00286 if(macroFileName=="***NULL***") 00287 { runManager->BeamOn(nev); } 00288 else 00289 { runManager->BeamOn(nev,macroFileName,nst); } 00290 } 00291 else if( command==verboseCmd ) 00292 { runManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); } 00293 else if( command==dumpRegCmd ) 00294 { 00295 if(newValue=="**ALL**") 00296 { runManager->DumpRegion(); } 00297 else 00298 { runManager->DumpRegion(newValue); } 00299 } 00300 else if( command==dumpCoupleCmd) 00301 { 00302 G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples(); 00303 } 00304 else if( command==optCmd ) 00305 { runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue)); } 00306 else if( command==brkBoECmd ) 00307 { G4UImanager::GetUIpointer()->SetPauseAtBeginOfEvent(brkBoECmd->GetNewBoolValue(newValue)); } 00308 else if( command==brkEoECmd ) 00309 { G4UImanager::GetUIpointer()->SetPauseAtEndOfEvent(brkEoECmd->GetNewBoolValue(newValue)); } 00310 else if( command==abortCmd ) 00311 { runManager->AbortRun(abortCmd->GetNewBoolValue(newValue)); } 00312 else if( command==abortEventCmd ) 00313 { runManager->AbortEvent(); } 00314 else if( command==initCmd ) 00315 { runManager->Initialize(); } 00316 else if( command==geomCmd ) 00317 { runManager->GeometryHasBeenModified(); } 00318 else if( command==physCmd ) 00319 { runManager->PhysicsHasBeenModified(); } 00320 else if( command==cutCmd ) 00321 { runManager->CutOffHasBeenModified(); } 00322 00323 else if( command==seedCmd ) 00324 { 00325 G4Tokenizer next(newValue); 00326 G4int idx=0; 00327 long seeds[100]; 00328 G4String vl; 00329 while(!(vl=next()).isNull()) 00330 { seeds[idx] = (long)(StoI(vl)); idx++; } 00331 if(idx<2) 00332 { G4cerr << "/random/setSeeds should have at least two integers. Command ignored." << G4endl; } 00333 else 00334 { 00335 seeds[idx] = 0; 00336 CLHEP::HepRandom::setTheSeeds(seeds); 00337 } 00338 } 00339 else if( command==randDirCmd ) 00340 { runManager->SetRandomNumberStoreDir(newValue); } 00341 else if( command==savingFlagCmd ) 00342 { runManager->SetRandomNumberStore(savingFlagCmd->GetNewBoolValue(newValue)); } 00343 else if( command==saveThisRunCmd ) 00344 { runManager->rndmSaveThisRun(); } 00345 else if( command==saveThisEventCmd ) 00346 { runManager->rndmSaveThisEvent(); } 00347 else if( command==restoreRandCmd ) 00348 { runManager->RestoreRandomNumberStatus(newValue); } 00349 else if( command==randEvtCmd ) 00350 { runManager->StoreRandomNumberStatusToG4Event(randEvtCmd->GetNewIntValue(newValue)); } 00351 00352 else if( command==randDirOld ) 00353 {G4cout << "warning: deprecated command. Use /random/setDirectoryName" 00354 << G4endl; 00355 // runManager->SetRandomNumberStoreDir(newValue); 00356 } 00357 else if( command==storeRandOld ) 00358 {G4cout << "warning: deprecated command. Use /random/setSavingFlag" 00359 << G4endl; 00360 // G4int frequency = storeRandOld->GetNewIntValue(newValue); 00361 // G4bool flag = false; 00362 // if(frequency != 0) flag = true; 00363 // runManager->SetRandomNumberStore(flag); 00364 } 00365 else if( command==restoreRandOld ) 00366 {G4cout << "warning: deprecated command. Use /random/resetEngineFrom" 00367 << G4endl; 00368 // runManager->RestoreRandomNumberStatus(newValue); 00369 } 00370 else if( command==constScoreCmd ) 00371 { runManager->ConstructScoringWorlds(); } 00372 00373 }