61 beamOnCmd->
SetGuidance(
"If G4 kernel is not initialized, it will be initialized.");
62 beamOnCmd->
SetGuidance(
"Default number of events to be processed is 1.");
63 beamOnCmd->
SetGuidance(
"The second and third arguments can be used for");
64 beamOnCmd->
SetGuidance(
"executing a macro file at the end of each event.");
65 beamOnCmd->
SetGuidance(
"If the second argument, i.e. name of the macro");
66 beamOnCmd->
SetGuidance(
"file, is given but the third argument is not,");
67 beamOnCmd->
SetGuidance(
"the macro file will be executed for all of the");
69 beamOnCmd->
SetGuidance(
"If the third argument (nSelect) is given, the");
70 beamOnCmd->
SetGuidance(
"macro file will be executed only for the first");
75 p1->SetDefaultValue(1);
76 p1->SetParameterRange(
"numberOfEvent >= 0");
79 p2->SetDefaultValue(
"***NULL***");
82 p3->SetDefaultValue(-1);
83 p3->SetParameterRange(
"nSelect>=-1");
88 verboseCmd->
SetGuidance(
"Set the Verbose level of G4RunManager.");
90 verboseCmd->
SetGuidance(
" 1 : Display main topics");
91 verboseCmd->
SetGuidance(
" 2 : Display main topics and run summary");
94 verboseCmd->
SetRange(
"level >=0 && level <=2");
97 printProgCmd->
SetGuidance(
"Display begin_of_event information at given frequency.");
98 printProgCmd->
SetGuidance(
"If it is set to zero, only the begin_of_run is shown.");
99 printProgCmd->
SetGuidance(
"If it is set to -1, no print-out is shown.");
105 nThreadsCmd->
SetGuidance(
"Set the number of threads to be used.");
106 nThreadsCmd->
SetGuidance(
"This command works only in PreInit state.");
107 nThreadsCmd->
SetGuidance(
"This command is valid only for multi-threaded mode.");
108 nThreadsCmd->
SetGuidance(
"The command is ignored if it is issued in sequential mode.");
111 nThreadsCmd->
SetRange(
"nThreads >0");
117 "Set the number of threads to be the number of available logical cores.");
118 maxThreadsCmd->
SetGuidance(
"This command works only in PreInit state.");
119 maxThreadsCmd->
SetGuidance(
"This command is valid only for multi-threaded mode.");
120 maxThreadsCmd->
SetGuidance(
"The command is ignored if it is issued in sequential mode.");
126 "Locks each thread to a specific logical core. Workers "
127 "are locked in round robin to logical cores.");
128 pinAffinityCmd->
SetGuidance(
"This command is valid only for multi-threaded mode.");
129 pinAffinityCmd->
SetGuidance(
"This command works only in PreInit state.");
130 pinAffinityCmd->
SetGuidance(
"This command is ignored if it is issued in sequential mode.");
132 "If a value n>0 is provided it starts setting affinity "
133 "from the n-th CPU (note: counting from 1).");
135 "E.g. /run/pinAffinity 3 locks first thread on "
136 "third logical CPU (number 2).");
137 pinAffinityCmd->
SetGuidance(
"If a value n<0 is provided never locks on n-th CPU.");
141 pinAffinityCmd->
SetRange(
"pinAffinity > 0 || pinAffinity < 0");
144 evModCmd =
new G4UIcommand(
"/run/eventModulo",
this);
145 evModCmd->
SetGuidance(
"Set the event modulo for dispatching events to worker threads");
146 evModCmd->
SetGuidance(
"i.e. each worker thread is ordered to simulate N events and then");
147 evModCmd->
SetGuidance(
"comes back to G4MTRunManager for next set.");
148 evModCmd->
SetGuidance(
"If it is set to zero (default value), N is roughly given by this.");
149 evModCmd->
SetGuidance(
" N = int( sqrt( number_of_events / number_of_threads ) )");
150 evModCmd->
SetGuidance(
"The value N may affect on the computing performance in particular");
151 evModCmd->
SetGuidance(
"if N is too small compared to the total number of events.");
152 evModCmd->
SetGuidance(
"The second parameter seedOnce specifies how frequently each worker");
153 evModCmd->
SetGuidance(
"thread is seeded by the random number sequence centrally managed");
154 evModCmd->
SetGuidance(
"by the master G4MTRunManager.");
155 evModCmd->
SetGuidance(
" - If seedOnce is set to 0 (default), seeds that are centrally managed");
156 evModCmd->
SetGuidance(
" by G4MTRunManager are set for every event of every worker thread.");
157 evModCmd->
SetGuidance(
" This option guarantees event reproducibility regardless of number");
159 evModCmd->
SetGuidance(
" - If seedOnce is set to 1, seeds are set only once for the first");
160 evModCmd->
SetGuidance(
" event of each run of each worker thread. Event reproducibility is");
161 evModCmd->
SetGuidance(
" guaranteed only if the same number of worker threads are used.");
162 evModCmd->
SetGuidance(
" On the other hand, this option offers better computing performance");
163 evModCmd->
SetGuidance(
" in particular for applications with relatively small primary");
164 evModCmd->
SetGuidance(
" particle energy and large number of events.");
165 evModCmd->
SetGuidance(
" - If seedOnce is set to 2, seeds are set only for the first event of");
166 evModCmd->
SetGuidance(
" group of N events. This option is reserved for the future use when");
167 evModCmd->
SetGuidance(
" Geant4 allows number of threads to be dynamically changed during an");
169 evModCmd->
SetGuidance(
"This command is valid only for multi-threaded mode.");
170 evModCmd->
SetGuidance(
"This command is ignored if it is issued in sequential mode.");
172 emp1->SetDefaultValue(0);
173 emp1->SetParameterRange(
"N >= 0");
176 emp2->SetDefaultValue(0);
177 emp2->SetParameterRange(
"seedOnce >= 0 && seedOnce <=2");
183 dumpRegCmd->
SetGuidance(
"Dump region information.");
184 dumpRegCmd->
SetGuidance(
"In case name of a region is not given, all regions will be displayed.");
190 dumpCoupleCmd->
SetGuidance(
"Dump material-cuts-couple information.");
191 dumpCoupleCmd->
SetGuidance(
"Note that material-cuts-couple information is updated");
192 dumpCoupleCmd->
SetGuidance(
"after BeamOn has started.");
196 optCmd->
SetGuidance(
"Set the optimization flag for geometry.");
197 optCmd->
SetGuidance(
"If it is set to TRUE, G4GeometryManager will optimize");
199 optCmd->
SetGuidance(
"GEANT4 is initialized with this flag as TRUE.");
205 brkBoECmd->
SetGuidance(
"Set a break point at the beginning of every event.");
210 brkEoECmd->
SetGuidance(
"Set a break point at the end of every event.");
215 abortCmd->
SetGuidance(
"Abort current run processing.");
217 "If softAbort is false (default), currently processing event "
218 "will be immediately aborted,");
220 "while softAbort is true, abortion occurs after "
221 "processing the current event.");
227 abortEventCmd->
SetGuidance(
"Abort currently processing event.");
231 geomCmd->
SetGuidance(
"Force geometry to be closed (re-voxellized) again.");
232 geomCmd->
SetGuidance(
"This command must be applied if geometry has been modified");
233 geomCmd->
SetGuidance(
" after the first initialization (or BeamOn).");
237 geomRebCmd->
SetGuidance(
"Force geometry to be rebuilt once again.");
238 geomRebCmd->
SetGuidance(
"This command must be applied if the user needs his/her");
239 geomRebCmd->
SetGuidance(
" detector construction to be reinvoked.");
240 geomRebCmd->
SetGuidance(
"/run/geometryModified is automatically issued with this command.");
246 physCmd->
SetGuidance(
"Force all physics tables recalculated again.");
247 physCmd->
SetGuidance(
"This command must be applied");
248 physCmd->
SetGuidance(
" if physics process has been modified after the");
249 physCmd->
SetGuidance(
" first initialization (or BeamOn).");
253 constScoreCmd->
SetGuidance(
"Construct scoring parallel world(s) if defined.");
255 "This command is not mandatory, but automatically "
256 "called when a run starts.");
258 "But the user may use this to visualize the scoring "
259 "world(s) before a run to start.");
263 randomDirectory->
SetGuidance(
"Random number status control commands.");
266 seedCmd->
SetGuidance(
"Initialize the random number generator with integer seed stream.");
267 seedCmd->
SetGuidance(
"Number of integers should be more than 1.");
269 "Actual number of integers to be used depends on the individual "
270 "random number engine.");
271#ifdef G4MULTITHREADED
272 seedCmd->
SetGuidance(
"This command sets the seeds for the master thread.");
279 randDirCmd->
SetGuidance(
"Define the directory name of the rndm status files.");
280 randDirCmd->
SetGuidance(
"Directory will be created if it does not exist.");
286 savingFlagCmd->
SetGuidance(
"The randomNumberStatus will be saved at :");
288 "beginning of run (currentRun.rndm) and "
289 "beginning of event (currentEvent.rndm) ");
294 saveThisRunCmd->
SetGuidance(
"copy currentRun.rndm to runXXX.rndm");
298 saveThisEventCmd->
SetGuidance(
"copy currentEvent.rndm to runXXXevtYYY.rndm");
302 restoreRandCmd->
SetGuidance(
"Reset the status of the rndm engine from a file.");
303 restoreRandCmd->
SetGuidance(
"See CLHEP manual for detail.");
304 restoreRandCmd->
SetGuidance(
"The engine status must be stored beforehand.");
306 "Directory of the status file should be set by"
307 " /random/setDirectoryName.");
313 restoreRandCmdMT =
new G4UIcmdWithABool(
"/random/resetEngineFromEachEvent",
this);
314 restoreRandCmdMT->
SetGuidance(
"Reset the status of the rndm engine from a file at each event.");
315 restoreRandCmdMT->
SetGuidance(
"Note that the file must follow the following naming convention:");
317 "run{#1}evt{#2}.rndm ; where #1 is the run "
318 "number and #2 is the event number.");
320 "For example to re-seed the first event of the first "
321 "run the file should be called run0evt0.rndm.");
323 "If for a specific run/event the file is not found, "
324 "the standard re-seeding strategy is used.");
326 "This command has meaning only in MT mode for "
327 "strong reproducibility studies.");
329 "Directory of the status file should be set by"
330 " /random/setDirectoryName.");
335 saveEachEventCmd->
SetGuidance(
"Save random number status at beginning of each event.");
336 saveEachEventCmd->
SetGuidance(
"File name contains run and event numbers: runXXXevtYYY.rndm");
341 randEvtCmd->
SetGuidance(
"Flag to store rndm status to G4Event object.");
342 randEvtCmd->
SetGuidance(
" flag = 0 : not store (default)");
343 randEvtCmd->
SetGuidance(
" flag = 1 : status before primary particle generation is stored");
345 " flag = 2 : status before event processing (after primary "
346 "particle generation) is stored");
347 randEvtCmd->
SetGuidance(
" flag = 3 : both are stored");
349 "Note: Some performance overhead may be seen by storing rndm "
350 "status, in particular");
352 "for the case of simplest geometry and small number of tracks per event.");
355 randEvtCmd->
SetRange(
"flag>=0 && flag<=3");
360 procUICmds->
SetGuidance(
"Force workers to process current stack of UI commands.");
361 procUICmds->
SetGuidance(
"This commands is meaningful only in MT mode.");
372 delete maxThreadsCmd;
373 delete pinAffinityCmd;
377 delete dumpCoupleCmd;
381 delete abortEventCmd;
387 delete constScoreCmd;
391 delete savingFlagCmd;
392 delete saveThisRunCmd;
393 delete saveThisEventCmd;
394 delete restoreRandCmd;
395 delete randomDirectory;
396 delete saveEachEventCmd;
401 delete restoreRandCmdMT;
407 if (command == beamOnCmd) {
410 const auto nv = (
const char*)newValue;
411 std::istringstream is(nv);
412 is >> nev >> macroFileName >> nst;
413 if (macroFileName ==
"***NULL***") {
417 runManager->
BeamOn(nev, macroFileName, nst);
420 else if (command == verboseCmd) {
423 else if (command == printProgCmd) {
426 else if (command == nThreadsCmd) {
433 G4cout <<
"*** /run/numberOfThreads command is issued in sequential mode."
434 <<
"\nCommand is ignored." <<
G4endl;
438 "/run/numberOfThreads command is issued to local thread.");
441 else if (command == maxThreadsCmd) {
448 G4cout <<
"*** /run/useMaximumLogicalCores command is issued in "
450 <<
"\nCommand is ignored." <<
G4endl;
454 "/run/useMaximumLogicalCores command is issued to local thread.");
457 else if (command == pinAffinityCmd) {
464 G4cout <<
"*** /run/pinAffinity command is issued in sequential mode."
465 <<
"\nCommand is ignored." <<
G4endl;
469 "/run/pinAffinity command is issued to local thread.");
472 else if (command == evModCmd) {
477 const auto nv = (
const char*)newValue;
478 std::istringstream is(nv);
479 is >> nevMod >> sOnce;
484 G4cout <<
"*** /run/eventModulo command is issued in sequential mode."
485 <<
"\nCommand is ignored." <<
G4endl;
489 "/run/eventModulo command is issued to local thread.");
492 else if (command == dumpRegCmd) {
493 if (newValue ==
"**ALL**") {
500 else if (command == dumpCoupleCmd) {
503 else if (command == optCmd) {
506 else if (command == brkBoECmd) {
509 else if (command == brkEoECmd) {
512 else if (command == abortCmd) {
515 else if (command == abortEventCmd) {
518 else if (command == initCmd) {
521 else if (command == geomCmd) {
524 else if (command == geomRebCmd) {
527 else if (command == physCmd) {
530 else if (command == seedCmd) {
535 while (!(vl = next()).empty()) {
536 seeds[idx] =
StoL(vl);
540 G4cerr <<
"/random/setSeeds should have at least two values. "
546 G4Random::setTheSeeds(seeds);
549 else if (command == randDirCmd) {
552 else if (command == savingFlagCmd) {
555 else if (command == saveThisRunCmd) {
558 else if (command == saveThisEventCmd) {
561 else if (command == restoreRandCmd) {
564 else if (command == randEvtCmd) {
567 else if (command == saveEachEventCmd) {
570 else if (command == constScoreCmd) {
573 else if (command == restoreRandCmdMT) {
576 else if (command == procUICmds) {
581 rm->RequestWorkersProcessCommandsStack();
585 "/run/workersProcessCmds command issued on a "
586 "non-G4MTRunManager class instance.");
590 G4cout <<
"*** /run/workersProcessCmds command is issued in sequential mode."
591 <<
"\nCommand is ignored." <<
G4endl;
595 "/run/workersProcessCmds command is issued to local thread.");
605 if (command == verboseCmd) {
608 else if (command == printProgCmd) {
611 else if (command == randDirCmd) {
614 else if (command == randEvtCmd) {
617 else if (command == nThreadsCmd) {
627 else if (command == evModCmd) {
634 G4cout <<
"*** /run/eventModulo command is valid only in MT mode." <<
G4endl;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static G4int SeedOncePerCommunication()
static void SetSeedOncePerCommunication(G4int val)
static G4ProductionCutsTable * GetProductionCutsTable()
virtual void AbortRun(G4bool softAbort=false)
virtual void Initialize()
virtual void RestoreRandomNumberStatus(const G4String &fileN)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void SetRandomNumberStoreDir(const G4String &dir)
virtual void rndmSaveThisEvent()
virtual void RestoreRndmEachEvent(G4bool)
virtual void AbortEvent()
virtual void rndmSaveThisRun()
virtual void BeamOn(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
RMType GetRunManagerType() const
void PhysicsHasBeenModified()
void SetVerboseLevel(G4int vl)
const G4String & GetRandomNumberStoreDir() const
void SetRandomNumberStorePerEvent(G4bool flag)
void GeometryHasBeenModified(G4bool prop=true)
void SetGeometryToBeOptimized(G4bool vl)
void StoreRandomNumberStatusToG4Event(G4int vl)
G4int GetFlagRandomNumberStatusToG4Event() const
void SetRandomNumberStore(G4bool flag)
void DumpRegion(const G4String &rname) const
G4int GetVerboseLevel() const
virtual void ConstructScoringWorlds()
void SetPrintProgress(G4int i)
G4RunMessenger(G4RunManager *runMgr)
void SetNewValue(G4UIcommand *command, G4String newValues) override
~G4RunMessenger() override
G4String GetCurrentValue(G4UIcommand *command) override
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
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)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
static G4String ConvertToString(G4bool boolVal)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void SetRange(const char *rs)
void AvailableForStates(G4ApplicationState s1)
void SetPauseAtBeginOfEvent(G4bool vl)
static G4UImanager * GetUIpointer()
void SetPauseAtEndOfEvent(G4bool vl)
G4long StoL(const G4String &s)
G4int G4GetNumberOfCores()