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