Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4RunMessenger.cc
Go to the documentation of this file.
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// G4RunMessenger implementation
27//
28// Original author: M.Asai, 1997
29// --------------------------------------------------------------------
30
31#include <sstream>
32
33#include "G4RunMessenger.hh"
34#include "G4MTRunManager.hh"
35#include "G4MaterialScanner.hh"
37#include "G4RunManager.hh"
38#include "G4Tokenizer.hh"
39#include "G4UIcmdWithABool.hh"
40#include "G4UIcmdWithAString.hh"
43#include "G4UIcommand.hh"
44#include "G4UIdirectory.hh"
45#include "G4UImanager.hh"
46#include "G4UIparameter.hh"
47#include "G4ios.hh"
48#include "Randomize.hh"
49
51 : runManager(runMgr)
52{
53 runDirectory = new G4UIdirectory("/run/");
54 runDirectory->SetGuidance("Run control commands.");
55
56 initCmd = new G4UIcmdWithoutParameter("/run/initialize", this);
57 initCmd->SetGuidance("Initialize G4 kernel.");
59
60 beamOnCmd = new G4UIcommand("/run/beamOn", this);
61 beamOnCmd->SetGuidance("Start a Run.");
62 beamOnCmd->SetGuidance(
63 "If G4 kernel is not initialized, it will be initialized.");
64 beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
65 beamOnCmd->SetGuidance("The second and third arguments can be used for");
66 beamOnCmd->SetGuidance("executing a macro file at the end of each event.");
67 beamOnCmd->SetGuidance("If the second argument, i.e. name of the macro");
68 beamOnCmd->SetGuidance("file, is given but the third argument is not,");
69 beamOnCmd->SetGuidance("the macro file will be executed for all of the");
70 beamOnCmd->SetGuidance("event.");
71 beamOnCmd->SetGuidance("If the third argument (nSelect) is given, the");
72 beamOnCmd->SetGuidance("macro file will be executed only for the first");
73 beamOnCmd->SetGuidance("nSelect events.");
75 beamOnCmd->SetToBeBroadcasted(false);
76 G4UIparameter* p1 = new G4UIparameter("numberOfEvent", 'i', true);
77 p1->SetDefaultValue(1);
78 p1->SetParameterRange("numberOfEvent >= 0");
79 beamOnCmd->SetParameter(p1);
80 G4UIparameter* p2 = new G4UIparameter("macroFile", 's', true);
81 p2->SetDefaultValue("***NULL***");
82 beamOnCmd->SetParameter(p2);
83 G4UIparameter* p3 = new G4UIparameter("nSelect", 'i', true);
84 p3->SetDefaultValue(-1);
85 p3->SetParameterRange("nSelect>=-1");
86 beamOnCmd->SetParameter(p3);
87 // beamOnCmd->SetToBeBroadcasted(false);
88
89 verboseCmd = new G4UIcmdWithAnInteger("/run/verbose", this);
90 verboseCmd->SetGuidance("Set the Verbose level of G4RunManager.");
91 verboseCmd->SetGuidance(" 0 : Silent (default)");
92 verboseCmd->SetGuidance(" 1 : Display main topics");
93 verboseCmd->SetGuidance(" 2 : Display main topics and run summary");
94 verboseCmd->SetParameterName("level", true);
95 verboseCmd->SetDefaultValue(0);
96 verboseCmd->SetRange("level >=0 && level <=2");
97
98 printProgCmd = new G4UIcmdWithAnInteger("/run/printProgress", this);
99 printProgCmd->SetGuidance(
100 "Display begin_of_event information at given frequency.");
101 printProgCmd->SetGuidance(
102 "If it is set to zero, only the begin_of_run is shown.");
103 printProgCmd->SetGuidance("If it is set to -1, no print-out is shown.");
104 printProgCmd->SetParameterName("mod", true);
105 printProgCmd->SetDefaultValue(-1);
106 printProgCmd->SetRange("mod>=-1");
107
108 nThreadsCmd = new G4UIcmdWithAnInteger("/run/numberOfThreads", this);
109 nThreadsCmd->SetGuidance("Set the number of threads to be used.");
110 nThreadsCmd->SetGuidance("This command works only in PreInit state.");
111 nThreadsCmd->SetGuidance(
112 "This command is valid only for multi-threaded mode.");
113 nThreadsCmd->SetGuidance(
114 "The command is ignored if it is issued in sequential mode.");
115 nThreadsCmd->SetParameterName("nThreads", true);
116 nThreadsCmd->SetDefaultValue(2);
117 nThreadsCmd->SetRange("nThreads >0");
118 nThreadsCmd->SetToBeBroadcasted(false);
120
121 maxThreadsCmd =
122 new G4UIcmdWithoutParameter("/run/useMaximumLogicalCores", this);
123 maxThreadsCmd->SetGuidance(
124 "Set the number of threads to be the number of available logical cores.");
125 maxThreadsCmd->SetGuidance("This command works only in PreInit state.");
126 maxThreadsCmd->SetGuidance(
127 "This command is valid only for multi-threaded mode.");
128 maxThreadsCmd->SetGuidance(
129 "The command is ignored if it is issued in sequential mode.");
130 maxThreadsCmd->SetToBeBroadcasted(false);
131 maxThreadsCmd->AvailableForStates(G4State_PreInit);
132
133 pinAffinityCmd = new G4UIcmdWithAnInteger("/run/pinAffinity", this);
134 pinAffinityCmd->SetGuidance(
135 "Locks each thread to a specific logical core. Workers "
136 "are locked in round robin to logical cores.");
137 pinAffinityCmd->SetGuidance(
138 "This command is valid only for multi-threaded mode.");
139 pinAffinityCmd->SetGuidance("This command works only in PreInit state.");
140 pinAffinityCmd->SetGuidance(
141 "This command is ignored if it is issued in sequential mode.");
142 pinAffinityCmd->SetGuidance(
143 "If a value n>0 is provided it starts setting affinity "
144 "from the n-th CPU (note: counting from 1).");
145 pinAffinityCmd->SetGuidance("E.g. /run/pinAffinity 3 locks first thread on "
146 "third logical CPU (number 2).");
147 pinAffinityCmd->SetGuidance(
148 "If a value n<0 is provided never locks on n-th CPU.");
149 pinAffinityCmd->SetParameterName("pinAffinity", true);
150 pinAffinityCmd->SetDefaultValue(1);
151 pinAffinityCmd->SetToBeBroadcasted(false);
152 pinAffinityCmd->SetRange("pinAffinity > 0 || pinAffinity < 0");
153 pinAffinityCmd->AvailableForStates(G4State_PreInit);
154
155 evModCmd = new G4UIcommand("/run/eventModulo", this);
156 evModCmd->SetGuidance(
157 "Set the event modulo for dispatching events to worker threads");
158 evModCmd->SetGuidance(
159 "i.e. each worker thread is ordered to simulate N events and then");
160 evModCmd->SetGuidance("comes back to G4MTRunManager for next set.");
161 evModCmd->SetGuidance(
162 "If it is set to zero (default value), N is roughly given by this.");
163 evModCmd->SetGuidance(
164 " N = int( sqrt( number_of_events / number_of_threads ) )");
165 evModCmd->SetGuidance(
166 "The value N may affect on the computing performance in particular");
167 evModCmd->SetGuidance(
168 "if N is too small compared to the total number of events.");
169 evModCmd->SetGuidance(
170 "The second parameter seedOnce specifies how frequently each worker");
171 evModCmd->SetGuidance(
172 "thread is seeded by the random number sequence centrally managed");
173 evModCmd->SetGuidance("by the master G4MTRunManager.");
174 evModCmd->SetGuidance(
175 " - If seedOnce is set to 0 (default), seeds that are centrally managed");
176 evModCmd->SetGuidance(
177 " by G4MTRunManager are set for every event of every worker thread.");
178 evModCmd->SetGuidance(
179 " This option guarantees event reproducibility regardless of number");
180 evModCmd->SetGuidance(" of threads.");
181 evModCmd->SetGuidance(
182 " - If seedOnce is set to 1, seeds are set only once for the first");
183 evModCmd->SetGuidance(
184 " event of each run of each worker thread. Event reproducibility is");
185 evModCmd->SetGuidance(
186 " guaranteed only if the same number of worker threads are used.");
187 evModCmd->SetGuidance(
188 " On the other hand, this option offers better computing performance");
189 evModCmd->SetGuidance(
190 " in particular for applications with relatively small primary");
191 evModCmd->SetGuidance(" particle energy and large number of events.");
192 evModCmd->SetGuidance(
193 " - If seedOnce is set to 2, seeds are set only for the first event of");
194 evModCmd->SetGuidance(
195 " group of N events. This option is reserved for the future use when");
196 evModCmd->SetGuidance(
197 " Geant4 allows number of threads to be dynamically changed during an");
198 evModCmd->SetGuidance(" event loop.");
199 evModCmd->SetGuidance("This command is valid only for multi-threaded mode.");
200 evModCmd->SetGuidance(
201 "This command is ignored if it is issued in sequential mode.");
202 G4UIparameter* emp1 = new G4UIparameter("N", 'i', true);
203 emp1->SetDefaultValue(0);
204 emp1->SetParameterRange("N >= 0");
205 evModCmd->SetParameter(emp1);
206 G4UIparameter* emp2 = new G4UIparameter("seedOnce", 'i', true);
207 emp2->SetDefaultValue(0);
208 emp2->SetParameterRange("seedOnce >= 0 && seedOnce <=2");
209 evModCmd->SetParameter(emp2);
210 evModCmd->SetToBeBroadcasted(false);
212
213 dumpRegCmd = new G4UIcmdWithAString("/run/dumpRegion", this);
214 dumpRegCmd->SetGuidance("Dump region information.");
215 dumpRegCmd->SetGuidance(
216 "In case name of a region is not given, all regions will be displayed.");
217 dumpRegCmd->SetParameterName("regionName", true);
218 dumpRegCmd->SetDefaultValue("**ALL**");
219 dumpRegCmd->AvailableForStates(G4State_Idle);
220
221 dumpCoupleCmd = new G4UIcmdWithoutParameter("/run/dumpCouples", this);
222 dumpCoupleCmd->SetGuidance("Dump material-cuts-couple information.");
223 dumpCoupleCmd->SetGuidance(
224 "Note that material-cuts-couple information is updated");
225 dumpCoupleCmd->SetGuidance("after BeamOn has started.");
226 dumpCoupleCmd->AvailableForStates(G4State_Idle);
227
228 optCmd = new G4UIcmdWithABool("/run/optimizeGeometry", this);
229 optCmd->SetGuidance("Set the optimization flag for geometry.");
230 optCmd->SetGuidance("If it is set to TRUE, G4GeometryManager will optimize");
231 optCmd->SetGuidance("the geometry definitions.");
232 optCmd->SetGuidance("GEANT4 is initialized with this flag as TRUE.");
233 optCmd->SetParameterName("optimizeFlag", true);
234 optCmd->SetDefaultValue(true);
236
237 brkBoECmd = new G4UIcmdWithABool("/run/breakAtBeginOfEvent", this);
238 brkBoECmd->SetGuidance("Set a break point at the beginning of every event.");
239 brkBoECmd->SetParameterName("flag", true);
240 brkBoECmd->SetDefaultValue(true);
241
242 brkEoECmd = new G4UIcmdWithABool("/run/breakAtEndOfEvent", this);
243 brkEoECmd->SetGuidance("Set a break point at the end of every event.");
244 brkEoECmd->SetParameterName("flag", true);
245 brkEoECmd->SetDefaultValue(true);
246
247 abortCmd = new G4UIcmdWithABool("/run/abort", this);
248 abortCmd->SetGuidance("Abort current run processing.");
249 abortCmd->SetGuidance(
250 "If softAbort is false (default), currently processing event "
251 "will be immediately aborted,");
252 abortCmd->SetGuidance("while softAbort is true, abortion occurs after "
253 "processing the current event.");
255 abortCmd->SetParameterName("softAbort", true);
256 abortCmd->SetDefaultValue(false);
257
258 abortEventCmd = new G4UIcmdWithoutParameter("/run/abortCurrentEvent", this);
259 abortEventCmd->SetGuidance("Abort currently processing event.");
261
262 geomCmd = new G4UIcmdWithoutParameter("/run/geometryModified", this);
263 geomCmd->SetGuidance("Force geometry to be closed (re-voxellized) again.");
264 geomCmd->SetGuidance(
265 "This command must be applied if geometry has been modified");
266 geomCmd->SetGuidance(" after the first initialization (or BeamOn).");
268
269 geomRebCmd = new G4UIcmdWithABool("/run/reinitializeGeometry", this);
270 geomRebCmd->SetGuidance("Force geometry to be rebuilt once again.");
271 geomRebCmd->SetGuidance(
272 "This command must be applied if the user needs his/her");
273 geomRebCmd->SetGuidance(" detector construction to be reinvoked.");
274 geomRebCmd->SetGuidance(
275 "/run/geometryModified is automatically issued with this command.");
276 geomRebCmd->SetParameterName("destroyFirst", true);
277 geomRebCmd->SetDefaultValue(false);
279
280 physCmd = new G4UIcmdWithoutParameter("/run/physicsModified", this);
281 physCmd->SetGuidance("Force all physics tables recalculated again.");
282 physCmd->SetGuidance("This command must be applied");
283 physCmd->SetGuidance(" if physics process has been modified after the");
284 physCmd->SetGuidance(" first initialization (or BeamOn).");
286
287 constScoreCmd =
288 new G4UIcmdWithoutParameter("/run/constructScoringWorlds", this);
289 constScoreCmd->SetGuidance("Construct scoring parallel world(s) if defined.");
290 constScoreCmd->SetGuidance("This command is not mandatory, but automatically "
291 "called when a run starts.");
292 constScoreCmd->SetGuidance(
293 "But the user may use this to visualize the scoring "
294 "world(s) before a run to start.");
295 constScoreCmd->AvailableForStates(G4State_Idle);
296
297 materialScanner = new G4MaterialScanner();
298
299 randomDirectory = new G4UIdirectory("/random/");
300 randomDirectory->SetGuidance("Random number status control commands.");
301
302 seedCmd = new G4UIcmdWithAString("/random/setSeeds", this);
303 seedCmd->SetGuidance(
304 "Initialize the random number generator with integer seed stream.");
305 seedCmd->SetGuidance("Number of integers should be more than 1.");
306 seedCmd->SetGuidance(
307 "Actual number of integers to be used depends on the individual "
308 "random number engine.");
309#ifdef G4MULTITHREADED
310 seedCmd->SetGuidance("This command sets the seeds for the master thread.");
311#endif
312 seedCmd->SetParameterName("IntArray", false);
315 seedCmd->SetToBeBroadcasted(false);
316
317 randDirCmd = new G4UIcmdWithAString("/random/setDirectoryName", this);
318 randDirCmd->SetGuidance(
319 "Define the directory name of the rndm status files.");
320 randDirCmd->SetGuidance("Directory will be created if it does not exist.");
321 randDirCmd->SetParameterName("fileName", true);
322 randDirCmd->SetDefaultValue("./");
325
326 savingFlagCmd = new G4UIcmdWithABool("/random/setSavingFlag", this);
327 savingFlagCmd->SetGuidance("The randomNumberStatus will be saved at :");
328 savingFlagCmd->SetGuidance("beginning of run (currentRun.rndm) and "
329 "beginning of event (currentEvent.rndm) ");
330 savingFlagCmd->SetParameterName("flag", true);
331 savingFlagCmd->SetDefaultValue(true);
332
333 saveThisRunCmd = new G4UIcmdWithoutParameter("/random/saveThisRun", this);
334 saveThisRunCmd->SetGuidance("copy currentRun.rndm to runXXX.rndm");
337
338 saveThisEventCmd = new G4UIcmdWithoutParameter("/random/saveThisEvent", this);
339 saveThisEventCmd->SetGuidance("copy currentEvent.rndm to runXXXevtYYY.rndm");
340 saveThisEventCmd->AvailableForStates(G4State_EventProc);
341
342 restoreRandCmd = new G4UIcmdWithAString("/random/resetEngineFrom", this);
343 restoreRandCmd->SetGuidance(
344 "Reset the status of the rndm engine from a file.");
345 restoreRandCmd->SetGuidance("See CLHEP manual for detail.");
346 restoreRandCmd->SetGuidance("The engine status must be stored beforehand.");
347 restoreRandCmd->SetGuidance("Directory of the status file should be set by"
348 " /random/setDirectoryName.");
349 restoreRandCmd->SetParameterName("fileName", true);
350 restoreRandCmd->SetDefaultValue("currentRun.rndm");
353 restoreRandCmd->SetToBeBroadcasted(false);
354
355 restoreRandCmdMT =
356 new G4UIcmdWithABool("/random/resetEngineFromEachEvent", this);
357 restoreRandCmdMT->SetGuidance(
358 "Reset the status of the rndm engine from a file at each event.");
359 restoreRandCmdMT->SetGuidance(
360 "Note that the file must follow the following naming convention:");
361 restoreRandCmdMT->SetGuidance("run{#1}evt{#2}.rndm ; where #1 is the run "
362 "number and #2 is the event number.");
363 restoreRandCmdMT->SetGuidance(
364 "For example to re-seed the first event of the first "
365 "run the file should be called run0evt0.rndm.");
366 restoreRandCmdMT->SetGuidance(
367 "If for a specific run/event the file is not found, "
368 "the standard re-seeding strategy is used.");
369 restoreRandCmdMT->SetGuidance("This command has meaning only in MT mode for "
370 "strong reproducibility studies.");
371 restoreRandCmdMT->SetGuidance("Directory of the status file should be set by"
372 " /random/setDirectoryName.");
373 restoreRandCmdMT->SetDefaultValue(false);
376
377 saveEachEventCmd = new G4UIcmdWithABool("/random/saveEachEventFlag", this);
378 saveEachEventCmd->SetGuidance(
379 "Save random number status at beginning of each event.");
380 saveEachEventCmd->SetGuidance(
381 "File name contains run and event numbers: runXXXevtYYY.rndm");
382 saveEachEventCmd->SetParameterName("flag", true);
383 saveEachEventCmd->SetDefaultValue(true);
384
385 randEvtCmd = new G4UIcmdWithAnInteger("/run/storeRndmStatToEvent", this);
386 randEvtCmd->SetGuidance("Flag to store rndm status to G4Event object.");
387 randEvtCmd->SetGuidance(" flag = 0 : not store (default)");
388 randEvtCmd->SetGuidance(
389 " flag = 1 : status before primary particle generation is stored");
390 randEvtCmd->SetGuidance(
391 " flag = 2 : status before event processing (after primary "
392 "particle generation) is stored");
393 randEvtCmd->SetGuidance(" flag = 3 : both are stored");
394 randEvtCmd->SetGuidance(
395 "Note: Some performance overhead may be seen by storing rndm "
396 "status, in particular");
397 randEvtCmd->SetGuidance(
398 "for the case of simplest geometry and small number of tracks per event.");
399 randEvtCmd->SetParameterName("flag", true);
400 randEvtCmd->SetDefaultValue(0);
401 randEvtCmd->SetRange("flag>=0 && flag<=3");
403
404 procUICmds = new G4UIcmdWithoutParameter("/run/workersProcessCmds", this);
405 procUICmds->SetToBeBroadcasted(false);
406 procUICmds->SetGuidance(
407 "Force workers to process current stack of UI commands.");
408 procUICmds->SetGuidance("This commands is meaningful only in MT mode.");
411}
412
413// --------------------------------------------------------------------
415{
416 delete materialScanner;
417 delete beamOnCmd;
418 delete verboseCmd;
419 delete printProgCmd;
420 delete nThreadsCmd;
421 delete maxThreadsCmd;
422 delete pinAffinityCmd;
423 delete evModCmd;
424 delete optCmd;
425 delete dumpRegCmd;
426 delete dumpCoupleCmd;
427 delete brkBoECmd;
428 delete brkEoECmd;
429 delete abortCmd;
430 delete abortEventCmd;
431 delete initCmd;
432 delete geomCmd;
433 delete geomRebCmd;
434 delete physCmd;
435 delete randEvtCmd;
436 delete constScoreCmd;
437 delete procUICmds;
438
439 delete seedCmd;
440 delete savingFlagCmd;
441 delete saveThisRunCmd;
442 delete saveThisEventCmd;
443 delete restoreRandCmd;
444 delete randomDirectory;
445 delete saveEachEventCmd;
446
447 delete randDirCmd;
448 delete runDirectory;
449
450 delete restoreRandCmdMT;
451}
452
453// --------------------------------------------------------------------
455{
456 if(command == beamOnCmd)
457 {
458 G4int nev;
459 G4int nst;
460 const char* nv = (const char*) newValue;
461 std::istringstream is(nv);
462 is >> nev >> macroFileName >> nst;
463 if(macroFileName == "***NULL***")
464 {
465 runManager->BeamOn(nev);
466 }
467 else
468 {
469 runManager->BeamOn(nev, macroFileName, nst);
470 }
471 }
472 else if(command == verboseCmd)
473 {
474 runManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
475 }
476 else if(command == printProgCmd)
477 {
478 runManager->SetPrintProgress(printProgCmd->GetNewIntValue(newValue));
479 }
480 else if(command == nThreadsCmd)
481 {
482 G4RunManager::RMType rmType = runManager->GetRunManagerType();
483 if(rmType == G4RunManager::masterRM)
484 {
485 static_cast<G4MTRunManager*>(runManager)
486 ->SetNumberOfThreads(nThreadsCmd->GetNewIntValue(newValue));
487 }
488 else if(rmType == G4RunManager::sequentialRM)
489 {
490 G4cout << "*** /run/numberOfThreads command is issued in sequential mode."
491 << "\nCommand is ignored." << G4endl;
492 }
493 else
494 {
495 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0901", FatalException,
496 "/run/numberOfThreads command is issued to local thread.");
497 }
498 }
499 else if(command == maxThreadsCmd)
500 {
501 G4RunManager::RMType rmType = runManager->GetRunManagerType();
502 if(rmType == G4RunManager::masterRM)
503 {
504 static_cast<G4MTRunManager*>(runManager)
505 ->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
506 }
507 else if(rmType == G4RunManager::sequentialRM)
508 {
509 G4cout << "*** /run/useMaximumLogicalCores command is issued in "
510 "sequential mode."
511 << "\nCommand is ignored." << G4endl;
512 }
513 else
514 {
516 "G4RunMessenger::ApplyNewCommand", "Run0901", FatalException,
517 "/run/useMaximumLogicalCores command is issued to local thread.");
518 }
519 }
520 else if(command == pinAffinityCmd)
521 {
522 G4RunManager::RMType rmType = runManager->GetRunManagerType();
523 if(rmType == G4RunManager::masterRM)
524 {
525 static_cast<G4MTRunManager*>(runManager)
526 ->SetPinAffinity(pinAffinityCmd->GetNewIntValue(newValue));
527 }
528 else if(rmType == G4RunManager::sequentialRM)
529 {
530 G4cout << "*** /run/pinAffinity command is issued in sequential mode."
531 << "\nCommand is ignored." << G4endl;
532 }
533 else
534 {
535 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0901", FatalException,
536 "/run/pinAffinity command is issued to local thread.");
537 }
538 }
539 else if(command == evModCmd)
540 {
541 G4RunManager::RMType rmType = runManager->GetRunManagerType();
542 if(rmType == G4RunManager::masterRM)
543 {
544 G4int nevMod = 0;
545 G4int sOnce = 0;
546 const char* nv = (const char*) newValue;
547 std::istringstream is(nv);
548 is >> nevMod >> sOnce;
549 static_cast<G4MTRunManager*>(runManager)->SetEventModulo(nevMod);
551 }
552 else if(rmType == G4RunManager::sequentialRM)
553 {
554 G4cout << "*** /run/eventModulo command is issued in sequential mode."
555 << "\nCommand is ignored." << G4endl;
556 }
557 else
558 {
559 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0902", FatalException,
560 "/run/eventModulo command is issued to local thread.");
561 }
562 }
563 else if(command == dumpRegCmd)
564 {
565 if(newValue == "**ALL**")
566 {
567 runManager->DumpRegion();
568 }
569 else
570 {
571 runManager->DumpRegion(newValue);
572 }
573 }
574 else if(command == dumpCoupleCmd)
575 {
577 }
578 else if(command == optCmd)
579 {
580 runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue));
581 }
582 else if(command == brkBoECmd)
583 {
585 brkBoECmd->GetNewBoolValue(newValue));
586 }
587 else if(command == brkEoECmd)
588 {
590 brkEoECmd->GetNewBoolValue(newValue));
591 }
592 else if(command == abortCmd)
593 {
594 runManager->AbortRun(abortCmd->GetNewBoolValue(newValue));
595 }
596 else if(command == abortEventCmd)
597 {
598 runManager->AbortEvent();
599 }
600 else if(command == initCmd)
601 {
602 runManager->Initialize();
603 }
604 else if(command == geomCmd)
605 {
606 runManager->GeometryHasBeenModified(false);
607 }
608 else if(command == geomRebCmd)
609 {
610 runManager->ReinitializeGeometry(geomRebCmd->GetNewBoolValue(newValue),
611 false);
612 }
613 else if(command == physCmd)
614 {
615 runManager->PhysicsHasBeenModified();
616 }
617 else if(command == seedCmd)
618 {
619 G4Tokenizer next(newValue);
620 G4int idx = 0;
621 G4long seeds[100];
622 G4String vl;
623 while(!(vl = next()).empty())
624 {
625 seeds[idx] = StoL(vl);
626 ++idx;
627 }
628 if(idx < 2)
629 {
630 G4cerr << "/random/setSeeds should have at least two values. "
631 "Command ignored."
632 << G4endl;
633 }
634 else
635 {
636 seeds[idx] = 0;
637 G4Random::setTheSeeds(seeds);
638 }
639 }
640 else if(command == randDirCmd)
641 {
642 runManager->SetRandomNumberStoreDir(newValue);
643 }
644 else if(command == savingFlagCmd)
645 {
646 runManager->SetRandomNumberStore(savingFlagCmd->GetNewBoolValue(newValue));
647 }
648 else if(command == saveThisRunCmd)
649 {
650 runManager->rndmSaveThisRun();
651 }
652 else if(command == saveThisEventCmd)
653 {
654 runManager->rndmSaveThisEvent();
655 }
656 else if(command == restoreRandCmd)
657 {
658 runManager->RestoreRandomNumberStatus(newValue);
659 }
660 else if(command == randEvtCmd)
661 {
663 randEvtCmd->GetNewIntValue(newValue));
664 }
665 else if(command == saveEachEventCmd)
666 {
668 saveEachEventCmd->GetNewBoolValue(newValue));
669 }
670 else if(command == constScoreCmd)
671 {
672 runManager->ConstructScoringWorlds();
673 }
674 else if(command == restoreRandCmdMT)
675 {
676 runManager->RestoreRndmEachEvent(
677 restoreRandCmdMT->GetNewBoolValue(newValue));
678 }
679 else if(command == procUICmds)
680 {
681 G4RunManager::RMType rmType = runManager->GetRunManagerType();
682 if(rmType == G4RunManager::masterRM)
683 {
684 auto rm = dynamic_cast<G4MTRunManager*>(runManager);
685 if(rm != nullptr)
686 {
688 }
689 else
690 {
691 G4Exception("G4RunManager::ApplyNewCommand", "Run0128", FatalException,
692 "/run/workersProcessCmds command issued on a "
693 "non-G4MTRunManager class instance.");
694 }
695 }
696 else if(rmType == G4RunManager::sequentialRM)
697 {
698 G4cout
699 << "*** /run/workersProcessCmds command is issued in sequential mode."
700 << "\nCommand is ignored." << G4endl;
701 }
702 else
703 {
704 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0129", FatalException,
705 "/run/workersProcessCmds command is issued to local thread.");
706 }
707 }
708}
709
710// --------------------------------------------------------------------
712{
713 G4String cv;
714
715 if(command == verboseCmd)
716 {
717 cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel());
718 }
719 else if(command == printProgCmd)
720 {
721 cv = printProgCmd->ConvertToString(runManager->GetPrintProgress());
722 }
723 else if(command == randDirCmd)
724 {
725 cv = runManager->GetRandomNumberStoreDir();
726 }
727 else if(command == randEvtCmd)
728 {
729 cv = randEvtCmd->ConvertToString(
731 }
732 else if(command == nThreadsCmd)
733 {
734 G4RunManager::RMType rmType = runManager->GetRunManagerType();
735 if(rmType == G4RunManager::masterRM)
736 {
737 cv = nThreadsCmd->ConvertToString(
738 static_cast<G4MTRunManager*>(runManager)->GetNumberOfThreads());
739 }
740 else if(rmType == G4RunManager::sequentialRM)
741 {
742 cv = "0";
743 }
744 }
745 else if(command == evModCmd)
746 {
747 G4RunManager::RMType rmType = runManager->GetRunManagerType();
748 if(rmType == G4RunManager::masterRM)
749 {
750 cv =
751 evModCmd->ConvertToString(
752 static_cast<G4MTRunManager*>(runManager)->GetEventModulo()) +
753 " " +
755 }
756 else if(rmType == G4RunManager::sequentialRM)
757 {
758 G4cout << "*** /run/eventModulo command is valid only in MT mode."
759 << G4endl;
760 }
761 }
762
763 return cv;
764}
@ G4State_EventProc
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
long G4long
Definition: G4Types.hh:87
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4int SeedOncePerCommunication()
static void SetSeedOncePerCommunication(G4int val)
virtual void RequestWorkersProcessCommandsStack()
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 GetPrintProgress()
G4int GetVerboseLevel() const
virtual void ConstructScoringWorlds()
void SetPrintProgress(G4int i)
G4RunMessenger(G4RunManager *runMgr)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
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)
Definition: G4UIcommand.hh:172
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:446
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
void SetRange(const char *rs)
Definition: G4UIcommand.hh:121
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:287
void SetPauseAtBeginOfEvent(G4bool vl)
Definition: G4UImanager.hh:177
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetPauseAtEndOfEvent(G4bool vl)
Definition: G4UImanager.hh:179
G4long StoL(const G4String &s)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:121