Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4RunMessenger implementation 26 // G4RunMessenger implementation 27 // 27 // 28 // Original author: M.Asai, 1997 28 // Original author: M.Asai, 1997 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4RunMessenger.hh" << 31 #include <sstream> 32 32 >> 33 #include "G4RunMessenger.hh" 33 #include "G4MTRunManager.hh" 34 #include "G4MTRunManager.hh" 34 #include "G4SubEvtRunManager.hh" << 35 #include "G4MaterialScanner.hh" 35 #include "G4ProductionCutsTable.hh" 36 #include "G4ProductionCutsTable.hh" 36 #include "G4RunManager.hh" 37 #include "G4RunManager.hh" 37 #include "G4Tokenizer.hh" 38 #include "G4Tokenizer.hh" 38 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAnInteger.hh" 41 #include "G4UIcmdWithAnInteger.hh" 41 #include "G4UIcmdWithoutParameter.hh" 42 #include "G4UIcmdWithoutParameter.hh" 42 #include "G4UIcommand.hh" 43 #include "G4UIcommand.hh" 43 #include "G4UIdirectory.hh" 44 #include "G4UIdirectory.hh" 44 #include "G4UImanager.hh" 45 #include "G4UImanager.hh" 45 #include "G4UIparameter.hh" 46 #include "G4UIparameter.hh" 46 #include "G4ios.hh" 47 #include "G4ios.hh" 47 #include "Randomize.hh" 48 #include "Randomize.hh" 48 49 49 #include <sstream> << 50 G4RunMessenger::G4RunMessenger(G4RunManager* runMgr) 50 << 51 : runManager(runMgr) 51 G4RunMessenger::G4RunMessenger(G4RunManager* r << 52 { 52 { 53 runDirectory = new G4UIdirectory("/run/"); 53 runDirectory = new G4UIdirectory("/run/"); 54 runDirectory->SetGuidance("Run control comma 54 runDirectory->SetGuidance("Run control commands."); 55 55 56 initCmd = new G4UIcmdWithoutParameter("/run/ 56 initCmd = new G4UIcmdWithoutParameter("/run/initialize", this); 57 initCmd->SetGuidance("Initialize G4 kernel." 57 initCmd->SetGuidance("Initialize G4 kernel."); 58 initCmd->AvailableForStates(G4State_PreInit, 58 initCmd->AvailableForStates(G4State_PreInit, G4State_Idle), 59 59 60 beamOnCmd = new G4UIcommand("/run/beamOn", 60 beamOnCmd = new G4UIcommand("/run/beamOn", this); 61 beamOnCmd->SetGuidance("Start a Run."); 61 beamOnCmd->SetGuidance("Start a Run."); 62 beamOnCmd->SetGuidance("If G4 kernel is not << 62 beamOnCmd->SetGuidance( >> 63 "If G4 kernel is not initialized, it will be initialized."); 63 beamOnCmd->SetGuidance("Default number of ev 64 beamOnCmd->SetGuidance("Default number of events to be processed is 1."); 64 beamOnCmd->SetGuidance("The second and third 65 beamOnCmd->SetGuidance("The second and third arguments can be used for"); 65 beamOnCmd->SetGuidance("executing a macro fi 66 beamOnCmd->SetGuidance("executing a macro file at the end of each event."); 66 beamOnCmd->SetGuidance("If the second argume 67 beamOnCmd->SetGuidance("If the second argument, i.e. name of the macro"); 67 beamOnCmd->SetGuidance("file, is given but t 68 beamOnCmd->SetGuidance("file, is given but the third argument is not,"); 68 beamOnCmd->SetGuidance("the macro file will 69 beamOnCmd->SetGuidance("the macro file will be executed for all of the"); 69 beamOnCmd->SetGuidance("event."); 70 beamOnCmd->SetGuidance("event."); 70 beamOnCmd->SetGuidance("If the third argumen 71 beamOnCmd->SetGuidance("If the third argument (nSelect) is given, the"); 71 beamOnCmd->SetGuidance("macro file will be e 72 beamOnCmd->SetGuidance("macro file will be executed only for the first"); 72 beamOnCmd->SetGuidance("nSelect events."); 73 beamOnCmd->SetGuidance("nSelect events."); 73 beamOnCmd->AvailableForStates(G4State_PreIni 74 beamOnCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 74 beamOnCmd->SetToBeBroadcasted(false); 75 beamOnCmd->SetToBeBroadcasted(false); 75 auto p1 = new G4UIparameter("numberOfEvent", << 76 G4UIparameter* p1 = new G4UIparameter("numberOfEvent", 'i', true); 76 p1->SetDefaultValue(1); 77 p1->SetDefaultValue(1); 77 p1->SetParameterRange("numberOfEvent >= 0"); 78 p1->SetParameterRange("numberOfEvent >= 0"); 78 beamOnCmd->SetParameter(p1); 79 beamOnCmd->SetParameter(p1); 79 auto p2 = new G4UIparameter("macroFile", 's' << 80 G4UIparameter* p2 = new G4UIparameter("macroFile", 's', true); 80 p2->SetDefaultValue("***NULL***"); 81 p2->SetDefaultValue("***NULL***"); 81 beamOnCmd->SetParameter(p2); 82 beamOnCmd->SetParameter(p2); 82 auto p3 = new G4UIparameter("nSelect", 'i', << 83 G4UIparameter* p3 = new G4UIparameter("nSelect", 'i', true); 83 p3->SetDefaultValue(-1); 84 p3->SetDefaultValue(-1); 84 p3->SetParameterRange("nSelect>=-1"); 85 p3->SetParameterRange("nSelect>=-1"); 85 beamOnCmd->SetParameter(p3); 86 beamOnCmd->SetParameter(p3); 86 // beamOnCmd->SetToBeBroadcasted(false); 87 // beamOnCmd->SetToBeBroadcasted(false); 87 88 88 verboseCmd = new G4UIcmdWithAnInteger("/run/ 89 verboseCmd = new G4UIcmdWithAnInteger("/run/verbose", this); 89 verboseCmd->SetGuidance("Set the Verbose lev 90 verboseCmd->SetGuidance("Set the Verbose level of G4RunManager."); 90 verboseCmd->SetGuidance(" 0 : Silent (defaul 91 verboseCmd->SetGuidance(" 0 : Silent (default)"); 91 verboseCmd->SetGuidance(" 1 : Display main t 92 verboseCmd->SetGuidance(" 1 : Display main topics"); 92 verboseCmd->SetGuidance(" 2 : Display main t 93 verboseCmd->SetGuidance(" 2 : Display main topics and run summary"); 93 verboseCmd->SetGuidance(" 3 : Display some a << 94 verboseCmd->SetGuidance(" 4 : Display detail << 95 verboseCmd->SetGuidance(" N.B. 3 or 4 may ca << 96 verboseCmd->SetParameterName("level", true); 94 verboseCmd->SetParameterName("level", true); 97 verboseCmd->SetDefaultValue(0); 95 verboseCmd->SetDefaultValue(0); 98 verboseCmd->SetRange("level >=0 && level <=4 << 96 verboseCmd->SetRange("level >=0 && level <=2"); 99 97 100 printProgCmd = new G4UIcmdWithAnInteger("/ru 98 printProgCmd = new G4UIcmdWithAnInteger("/run/printProgress", this); 101 printProgCmd->SetGuidance("Display begin_of_ << 99 printProgCmd->SetGuidance( 102 printProgCmd->SetGuidance("If it is set to z << 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 - 103 printProgCmd->SetGuidance("If it is set to -1, no print-out is shown."); 104 printProgCmd->SetParameterName("mod", true); 104 printProgCmd->SetParameterName("mod", true); 105 printProgCmd->SetDefaultValue(-1); 105 printProgCmd->SetDefaultValue(-1); 106 printProgCmd->SetRange("mod>=-1"); 106 printProgCmd->SetRange("mod>=-1"); 107 107 108 nThreadsCmd = new G4UIcmdWithAnInteger("/run 108 nThreadsCmd = new G4UIcmdWithAnInteger("/run/numberOfThreads", this); 109 nThreadsCmd->SetGuidance("Set the number of 109 nThreadsCmd->SetGuidance("Set the number of threads to be used."); 110 nThreadsCmd->SetGuidance("This command works 110 nThreadsCmd->SetGuidance("This command works only in PreInit state."); 111 nThreadsCmd->SetGuidance("This command is va << 111 nThreadsCmd->SetGuidance( 112 nThreadsCmd->SetGuidance("The command is ign << 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."); 113 nThreadsCmd->SetParameterName("nThreads", tr 115 nThreadsCmd->SetParameterName("nThreads", true); 114 nThreadsCmd->SetDefaultValue(2); 116 nThreadsCmd->SetDefaultValue(2); 115 nThreadsCmd->SetRange("nThreads >0"); 117 nThreadsCmd->SetRange("nThreads >0"); 116 nThreadsCmd->SetToBeBroadcasted(false); 118 nThreadsCmd->SetToBeBroadcasted(false); 117 nThreadsCmd->AvailableForStates(G4State_PreI 119 nThreadsCmd->AvailableForStates(G4State_PreInit); 118 120 119 maxThreadsCmd = new G4UIcmdWithoutParameter( << 121 maxThreadsCmd = >> 122 new G4UIcmdWithoutParameter("/run/useMaximumLogicalCores", this); 120 maxThreadsCmd->SetGuidance( 123 maxThreadsCmd->SetGuidance( 121 "Set the number of threads to be the numbe 124 "Set the number of threads to be the number of available logical cores."); 122 maxThreadsCmd->SetGuidance("This command wor 125 maxThreadsCmd->SetGuidance("This command works only in PreInit state."); 123 maxThreadsCmd->SetGuidance("This command is << 126 maxThreadsCmd->SetGuidance( 124 maxThreadsCmd->SetGuidance("The command is i << 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."); 125 maxThreadsCmd->SetToBeBroadcasted(false); 130 maxThreadsCmd->SetToBeBroadcasted(false); 126 maxThreadsCmd->AvailableForStates(G4State_Pr 131 maxThreadsCmd->AvailableForStates(G4State_PreInit); 127 132 128 pinAffinityCmd = new G4UIcmdWithAnInteger("/ 133 pinAffinityCmd = new G4UIcmdWithAnInteger("/run/pinAffinity", this); 129 pinAffinityCmd->SetGuidance( 134 pinAffinityCmd->SetGuidance( 130 "Locks each thread to a specific logical c 135 "Locks each thread to a specific logical core. Workers " 131 "are locked in round robin to logical core 136 "are locked in round robin to logical cores."); 132 pinAffinityCmd->SetGuidance("This command is << 137 pinAffinityCmd->SetGuidance( >> 138 "This command is valid only for multi-threaded mode."); 133 pinAffinityCmd->SetGuidance("This command wo 139 pinAffinityCmd->SetGuidance("This command works only in PreInit state."); 134 pinAffinityCmd->SetGuidance("This command is << 140 pinAffinityCmd->SetGuidance( >> 141 "This command is ignored if it is issued in sequential mode."); 135 pinAffinityCmd->SetGuidance( 142 pinAffinityCmd->SetGuidance( 136 "If a value n>0 is provided it starts sett 143 "If a value n>0 is provided it starts setting affinity " 137 "from the n-th CPU (note: counting from 1) 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)."); 138 pinAffinityCmd->SetGuidance( 147 pinAffinityCmd->SetGuidance( 139 "E.g. /run/pinAffinity 3 locks first threa << 148 "If a value n<0 is provided never locks on n-th CPU."); 140 "third logical CPU (number 2)."); << 141 pinAffinityCmd->SetGuidance("If a value n<0 << 142 pinAffinityCmd->SetParameterName("pinAffinit 149 pinAffinityCmd->SetParameterName("pinAffinity", true); 143 pinAffinityCmd->SetDefaultValue(1); 150 pinAffinityCmd->SetDefaultValue(1); 144 pinAffinityCmd->SetToBeBroadcasted(false); 151 pinAffinityCmd->SetToBeBroadcasted(false); 145 pinAffinityCmd->SetRange("pinAffinity > 0 || 152 pinAffinityCmd->SetRange("pinAffinity > 0 || pinAffinity < 0"); 146 pinAffinityCmd->AvailableForStates(G4State_P 153 pinAffinityCmd->AvailableForStates(G4State_PreInit); 147 154 148 evModCmd = new G4UIcommand("/run/eventModulo 155 evModCmd = new G4UIcommand("/run/eventModulo", this); 149 evModCmd->SetGuidance("Set the event modulo << 156 evModCmd->SetGuidance( 150 evModCmd->SetGuidance("i.e. each worker thre << 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"); 151 evModCmd->SetGuidance("comes back to G4MTRun 160 evModCmd->SetGuidance("comes back to G4MTRunManager for next set."); 152 evModCmd->SetGuidance("If it is set to zero << 161 evModCmd->SetGuidance( 153 evModCmd->SetGuidance(" N = int( sqrt( num << 162 "If it is set to zero (default value), N is roughly given by this."); 154 evModCmd->SetGuidance("The value N may affec << 163 evModCmd->SetGuidance( 155 evModCmd->SetGuidance("if N is too small com << 164 " N = int( sqrt( number_of_events / number_of_threads ) )"); 156 evModCmd->SetGuidance("The second parameter << 165 evModCmd->SetGuidance( 157 evModCmd->SetGuidance("thread is seeded by t << 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"); 158 evModCmd->SetGuidance("by the master G4MTRun 173 evModCmd->SetGuidance("by the master G4MTRunManager."); 159 evModCmd->SetGuidance(" - If seedOnce is set << 174 evModCmd->SetGuidance( 160 evModCmd->SetGuidance(" by G4MTRunManager << 175 " - If seedOnce is set to 0 (default), seeds that are centrally managed"); 161 evModCmd->SetGuidance(" This option guaran << 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"); 162 evModCmd->SetGuidance(" of threads."); 180 evModCmd->SetGuidance(" of threads."); 163 evModCmd->SetGuidance(" - If seedOnce is set << 181 evModCmd->SetGuidance( 164 evModCmd->SetGuidance(" event of each run << 182 " - If seedOnce is set to 1, seeds are set only once for the first"); 165 evModCmd->SetGuidance(" guaranteed only if << 183 evModCmd->SetGuidance( 166 evModCmd->SetGuidance(" On the other hand, << 184 " event of each run of each worker thread. Event reproducibility is"); 167 evModCmd->SetGuidance(" in particular for << 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"); 168 evModCmd->SetGuidance(" particle energy an 191 evModCmd->SetGuidance(" particle energy and large number of events."); 169 evModCmd->SetGuidance(" - If seedOnce is set << 192 evModCmd->SetGuidance( 170 evModCmd->SetGuidance(" group of N events. << 193 " - If seedOnce is set to 2, seeds are set only for the first event of"); 171 evModCmd->SetGuidance(" Geant4 allows numb << 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"); 172 evModCmd->SetGuidance(" event loop."); 198 evModCmd->SetGuidance(" event loop."); 173 evModCmd->SetGuidance("This command is valid << 199 evModCmd->SetGuidance("This command is valid only for multi-threaded mode."); 174 evModCmd->SetGuidance("This command is ignor << 200 evModCmd->SetGuidance( 175 evModCmd->SetGuidance("sub-event parallel mo << 201 "This command is ignored if it is issued in sequential mode."); 176 auto emp1 = new G4UIparameter("N", 'i', true << 202 G4UIparameter* emp1 = new G4UIparameter("N", 'i', true); 177 emp1->SetDefaultValue(0); 203 emp1->SetDefaultValue(0); 178 emp1->SetParameterRange("N >= 0"); 204 emp1->SetParameterRange("N >= 0"); 179 evModCmd->SetParameter(emp1); 205 evModCmd->SetParameter(emp1); 180 auto emp2 = new G4UIparameter("seedOnce", 'i << 206 G4UIparameter* emp2 = new G4UIparameter("seedOnce", 'i', true); 181 emp2->SetDefaultValue(0); 207 emp2->SetDefaultValue(0); 182 emp2->SetParameterRange("seedOnce >= 0 && se 208 emp2->SetParameterRange("seedOnce >= 0 && seedOnce <=2"); 183 evModCmd->SetParameter(emp2); 209 evModCmd->SetParameter(emp2); 184 evModCmd->SetToBeBroadcasted(false); 210 evModCmd->SetToBeBroadcasted(false); 185 evModCmd->AvailableForStates(G4State_PreInit 211 evModCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 186 212 187 dumpRegCmd = new G4UIcmdWithAString("/run/du 213 dumpRegCmd = new G4UIcmdWithAString("/run/dumpRegion", this); 188 dumpRegCmd->SetGuidance("Dump region informa 214 dumpRegCmd->SetGuidance("Dump region information."); 189 dumpRegCmd->SetGuidance("In case name of a r << 215 dumpRegCmd->SetGuidance( >> 216 "In case name of a region is not given, all regions will be displayed."); 190 dumpRegCmd->SetParameterName("regionName", t 217 dumpRegCmd->SetParameterName("regionName", true); 191 dumpRegCmd->SetDefaultValue("**ALL**"); 218 dumpRegCmd->SetDefaultValue("**ALL**"); 192 dumpRegCmd->AvailableForStates(G4State_Idle) 219 dumpRegCmd->AvailableForStates(G4State_Idle); 193 220 194 dumpCoupleCmd = new G4UIcmdWithoutParameter( 221 dumpCoupleCmd = new G4UIcmdWithoutParameter("/run/dumpCouples", this); 195 dumpCoupleCmd->SetGuidance("Dump material-cu 222 dumpCoupleCmd->SetGuidance("Dump material-cuts-couple information."); 196 dumpCoupleCmd->SetGuidance("Note that materi << 223 dumpCoupleCmd->SetGuidance( >> 224 "Note that material-cuts-couple information is updated"); 197 dumpCoupleCmd->SetGuidance("after BeamOn has 225 dumpCoupleCmd->SetGuidance("after BeamOn has started."); 198 dumpCoupleCmd->AvailableForStates(G4State_Id 226 dumpCoupleCmd->AvailableForStates(G4State_Idle); 199 227 200 optCmd = new G4UIcmdWithABool("/run/optimize 228 optCmd = new G4UIcmdWithABool("/run/optimizeGeometry", this); 201 optCmd->SetGuidance("Set the optimization fl 229 optCmd->SetGuidance("Set the optimization flag for geometry."); 202 optCmd->SetGuidance("If it is set to TRUE, G 230 optCmd->SetGuidance("If it is set to TRUE, G4GeometryManager will optimize"); 203 optCmd->SetGuidance("the geometry definition 231 optCmd->SetGuidance("the geometry definitions."); 204 optCmd->SetGuidance("GEANT4 is initialized w 232 optCmd->SetGuidance("GEANT4 is initialized with this flag as TRUE."); 205 optCmd->SetParameterName("optimizeFlag", tru 233 optCmd->SetParameterName("optimizeFlag", true); 206 optCmd->SetDefaultValue(true); 234 optCmd->SetDefaultValue(true); 207 optCmd->AvailableForStates(G4State_PreInit, 235 optCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 208 236 209 brkBoECmd = new G4UIcmdWithABool("/run/break 237 brkBoECmd = new G4UIcmdWithABool("/run/breakAtBeginOfEvent", this); 210 brkBoECmd->SetGuidance("Set a break point at 238 brkBoECmd->SetGuidance("Set a break point at the beginning of every event."); 211 brkBoECmd->SetParameterName("flag", true); 239 brkBoECmd->SetParameterName("flag", true); 212 brkBoECmd->SetDefaultValue(true); 240 brkBoECmd->SetDefaultValue(true); 213 241 214 brkEoECmd = new G4UIcmdWithABool("/run/break 242 brkEoECmd = new G4UIcmdWithABool("/run/breakAtEndOfEvent", this); 215 brkEoECmd->SetGuidance("Set a break point at 243 brkEoECmd->SetGuidance("Set a break point at the end of every event."); 216 brkEoECmd->SetParameterName("flag", true); 244 brkEoECmd->SetParameterName("flag", true); 217 brkEoECmd->SetDefaultValue(true); 245 brkEoECmd->SetDefaultValue(true); 218 246 219 abortCmd = new G4UIcmdWithABool("/run/abort" 247 abortCmd = new G4UIcmdWithABool("/run/abort", this); 220 abortCmd->SetGuidance("Abort current run pro 248 abortCmd->SetGuidance("Abort current run processing."); 221 abortCmd->SetGuidance( 249 abortCmd->SetGuidance( 222 "If softAbort is false (default), currentl 250 "If softAbort is false (default), currently processing event " 223 "will be immediately aborted,"); 251 "will be immediately aborted,"); 224 abortCmd->SetGuidance( << 252 abortCmd->SetGuidance("while softAbort is true, abortion occurs after " 225 "while softAbort is true, abortion occurs << 253 "processing the current event."); 226 "processing the current event."); << 227 abortCmd->AvailableForStates(G4State_GeomClo 254 abortCmd->AvailableForStates(G4State_GeomClosed, G4State_EventProc); 228 abortCmd->SetParameterName("softAbort", true 255 abortCmd->SetParameterName("softAbort", true); 229 abortCmd->SetDefaultValue(false); 256 abortCmd->SetDefaultValue(false); 230 257 231 abortEventCmd = new G4UIcmdWithoutParameter( 258 abortEventCmd = new G4UIcmdWithoutParameter("/run/abortCurrentEvent", this); 232 abortEventCmd->SetGuidance("Abort currently 259 abortEventCmd->SetGuidance("Abort currently processing event."); 233 abortEventCmd->AvailableForStates(G4State_Ev 260 abortEventCmd->AvailableForStates(G4State_EventProc); 234 261 235 geomCmd = new G4UIcmdWithoutParameter("/run/ 262 geomCmd = new G4UIcmdWithoutParameter("/run/geometryModified", this); 236 geomCmd->SetGuidance("Force geometry to be c 263 geomCmd->SetGuidance("Force geometry to be closed (re-voxellized) again."); 237 geomCmd->SetGuidance("This command must be a << 264 geomCmd->SetGuidance( >> 265 "This command must be applied if geometry has been modified"); 238 geomCmd->SetGuidance(" after the first initi 266 geomCmd->SetGuidance(" after the first initialization (or BeamOn)."); 239 geomCmd->AvailableForStates(G4State_PreInit, 267 geomCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 240 268 241 geomRebCmd = new G4UIcmdWithABool("/run/rein 269 geomRebCmd = new G4UIcmdWithABool("/run/reinitializeGeometry", this); 242 geomRebCmd->SetGuidance("Force geometry to b 270 geomRebCmd->SetGuidance("Force geometry to be rebuilt once again."); 243 geomRebCmd->SetGuidance("This command must b << 271 geomRebCmd->SetGuidance( >> 272 "This command must be applied if the user needs his/her"); 244 geomRebCmd->SetGuidance(" detector construct 273 geomRebCmd->SetGuidance(" detector construction to be reinvoked."); 245 geomRebCmd->SetGuidance("/run/geometryModifi << 274 geomRebCmd->SetGuidance( >> 275 "/run/geometryModified is automatically issued with this command."); 246 geomRebCmd->SetParameterName("destroyFirst", 276 geomRebCmd->SetParameterName("destroyFirst", true); 247 geomRebCmd->SetDefaultValue(false); 277 geomRebCmd->SetDefaultValue(false); 248 geomRebCmd->AvailableForStates(G4State_PreIn 278 geomRebCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 249 279 250 physCmd = new G4UIcmdWithoutParameter("/run/ 280 physCmd = new G4UIcmdWithoutParameter("/run/physicsModified", this); 251 physCmd->SetGuidance("Force all physics tabl 281 physCmd->SetGuidance("Force all physics tables recalculated again."); 252 physCmd->SetGuidance("This command must be a 282 physCmd->SetGuidance("This command must be applied"); 253 physCmd->SetGuidance(" if physics process ha 283 physCmd->SetGuidance(" if physics process has been modified after the"); 254 physCmd->SetGuidance(" first initialization 284 physCmd->SetGuidance(" first initialization (or BeamOn)."); 255 physCmd->AvailableForStates(G4State_PreInit, 285 physCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 256 286 257 constScoreCmd = new G4UIcmdWithoutParameter( << 287 constScoreCmd = >> 288 new G4UIcmdWithoutParameter("/run/constructScoringWorlds", this); 258 constScoreCmd->SetGuidance("Construct scorin 289 constScoreCmd->SetGuidance("Construct scoring parallel world(s) if defined."); 259 constScoreCmd->SetGuidance( << 290 constScoreCmd->SetGuidance("This command is not mandatory, but automatically " 260 "This command is not mandatory, but automa << 291 "called when a run starts."); 261 "called when a run starts."); << 262 constScoreCmd->SetGuidance( 292 constScoreCmd->SetGuidance( 263 "But the user may use this to visualize th 293 "But the user may use this to visualize the scoring " 264 "world(s) before a run to start."); 294 "world(s) before a run to start."); 265 constScoreCmd->AvailableForStates(G4State_Id 295 constScoreCmd->AvailableForStates(G4State_Idle); 266 296 >> 297 materialScanner = new G4MaterialScanner(); >> 298 267 randomDirectory = new G4UIdirectory("/random 299 randomDirectory = new G4UIdirectory("/random/"); 268 randomDirectory->SetGuidance("Random number 300 randomDirectory->SetGuidance("Random number status control commands."); 269 301 270 seedCmd = new G4UIcmdWithAString("/random/se 302 seedCmd = new G4UIcmdWithAString("/random/setSeeds", this); 271 seedCmd->SetGuidance("Initialize the random << 303 seedCmd->SetGuidance( >> 304 "Initialize the random number generator with integer seed stream."); 272 seedCmd->SetGuidance("Number of integers sho 305 seedCmd->SetGuidance("Number of integers should be more than 1."); 273 seedCmd->SetGuidance( 306 seedCmd->SetGuidance( 274 "Actual number of integers to be used depe 307 "Actual number of integers to be used depends on the individual " 275 "random number engine."); 308 "random number engine."); 276 #ifdef G4MULTITHREADED 309 #ifdef G4MULTITHREADED 277 seedCmd->SetGuidance("This command sets the 310 seedCmd->SetGuidance("This command sets the seeds for the master thread."); 278 #endif 311 #endif 279 seedCmd->SetParameterName("IntArray", false) 312 seedCmd->SetParameterName("IntArray", false); 280 seedCmd->AvailableForStates(G4State_PreInit, << 313 seedCmd->AvailableForStates(G4State_PreInit, G4State_Idle, >> 314 G4State_GeomClosed); 281 seedCmd->SetToBeBroadcasted(false); 315 seedCmd->SetToBeBroadcasted(false); 282 316 283 randDirCmd = new G4UIcmdWithAString("/random 317 randDirCmd = new G4UIcmdWithAString("/random/setDirectoryName", this); 284 randDirCmd->SetGuidance("Define the director << 318 randDirCmd->SetGuidance( >> 319 "Define the directory name of the rndm status files."); 285 randDirCmd->SetGuidance("Directory will be c 320 randDirCmd->SetGuidance("Directory will be created if it does not exist."); 286 randDirCmd->SetParameterName("fileName", tru 321 randDirCmd->SetParameterName("fileName", true); 287 randDirCmd->SetDefaultValue("./"); 322 randDirCmd->SetDefaultValue("./"); 288 randDirCmd->AvailableForStates(G4State_PreIn << 323 randDirCmd->AvailableForStates(G4State_PreInit, G4State_Idle, >> 324 G4State_GeomClosed); 289 325 290 savingFlagCmd = new G4UIcmdWithABool("/rando 326 savingFlagCmd = new G4UIcmdWithABool("/random/setSavingFlag", this); 291 savingFlagCmd->SetGuidance("The randomNumber 327 savingFlagCmd->SetGuidance("The randomNumberStatus will be saved at :"); 292 savingFlagCmd->SetGuidance( << 328 savingFlagCmd->SetGuidance("beginning of run (currentRun.rndm) and " 293 "beginning of run (currentRun.rndm) and " << 329 "beginning of event (currentEvent.rndm) "); 294 "beginning of event (currentEvent.rndm) ") << 295 savingFlagCmd->SetParameterName("flag", true 330 savingFlagCmd->SetParameterName("flag", true); 296 savingFlagCmd->SetDefaultValue(true); 331 savingFlagCmd->SetDefaultValue(true); 297 332 298 saveThisRunCmd = new G4UIcmdWithoutParameter 333 saveThisRunCmd = new G4UIcmdWithoutParameter("/random/saveThisRun", this); 299 saveThisRunCmd->SetGuidance("copy currentRun 334 saveThisRunCmd->SetGuidance("copy currentRun.rndm to runXXX.rndm"); 300 saveThisRunCmd->AvailableForStates(G4State_I << 335 saveThisRunCmd->AvailableForStates(G4State_Idle, G4State_GeomClosed, >> 336 G4State_EventProc); 301 337 302 saveThisEventCmd = new G4UIcmdWithoutParamet 338 saveThisEventCmd = new G4UIcmdWithoutParameter("/random/saveThisEvent", this); 303 saveThisEventCmd->SetGuidance("copy currentE 339 saveThisEventCmd->SetGuidance("copy currentEvent.rndm to runXXXevtYYY.rndm"); 304 saveThisEventCmd->AvailableForStates(G4State 340 saveThisEventCmd->AvailableForStates(G4State_EventProc); 305 341 306 restoreRandCmd = new G4UIcmdWithAString("/ra 342 restoreRandCmd = new G4UIcmdWithAString("/random/resetEngineFrom", this); 307 restoreRandCmd->SetGuidance("Reset the statu << 343 restoreRandCmd->SetGuidance( >> 344 "Reset the status of the rndm engine from a file."); 308 restoreRandCmd->SetGuidance("See CLHEP manua 345 restoreRandCmd->SetGuidance("See CLHEP manual for detail."); 309 restoreRandCmd->SetGuidance("The engine stat 346 restoreRandCmd->SetGuidance("The engine status must be stored beforehand."); 310 restoreRandCmd->SetGuidance( << 347 restoreRandCmd->SetGuidance("Directory of the status file should be set by" 311 "Directory of the status file should be se << 348 " /random/setDirectoryName."); 312 " /random/setDirectoryName."); << 313 restoreRandCmd->SetParameterName("fileName", 349 restoreRandCmd->SetParameterName("fileName", true); 314 restoreRandCmd->SetDefaultValue("currentRun. 350 restoreRandCmd->SetDefaultValue("currentRun.rndm"); 315 restoreRandCmd->AvailableForStates(G4State_P << 351 restoreRandCmd->AvailableForStates(G4State_PreInit, G4State_Idle, >> 352 G4State_GeomClosed); 316 restoreRandCmd->SetToBeBroadcasted(false); 353 restoreRandCmd->SetToBeBroadcasted(false); 317 354 318 restoreRandCmdMT = new G4UIcmdWithABool("/ra << 355 restoreRandCmdMT = 319 restoreRandCmdMT->SetGuidance("Reset the sta << 356 new G4UIcmdWithABool("/random/resetEngineFromEachEvent", this); 320 restoreRandCmdMT->SetGuidance("Note that the << 357 restoreRandCmdMT->SetGuidance( >> 358 "Reset the status of the rndm engine from a file at each event."); 321 restoreRandCmdMT->SetGuidance( 359 restoreRandCmdMT->SetGuidance( 322 "run{#1}evt{#2}.rndm ; where #1 is the run << 360 "Note that the file must follow the following naming convention:"); 323 "number and #2 is the event number."); << 361 restoreRandCmdMT->SetGuidance("run{#1}evt{#2}.rndm ; where #1 is the run " >> 362 "number and #2 is the event number."); 324 restoreRandCmdMT->SetGuidance( 363 restoreRandCmdMT->SetGuidance( 325 "For example to re-seed the first event of 364 "For example to re-seed the first event of the first " 326 "run the file should be called run0evt0.rn 365 "run the file should be called run0evt0.rndm."); 327 restoreRandCmdMT->SetGuidance( 366 restoreRandCmdMT->SetGuidance( 328 "If for a specific run/event the file is n 367 "If for a specific run/event the file is not found, " 329 "the standard re-seeding strategy is used. 368 "the standard re-seeding strategy is used."); 330 restoreRandCmdMT->SetGuidance( << 369 restoreRandCmdMT->SetGuidance("This command has meaning only in MT mode for " 331 "This command has meaning only in MT mode << 370 "strong reproducibility studies."); 332 "strong reproducibility studies."); << 371 restoreRandCmdMT->SetGuidance("Directory of the status file should be set by" 333 restoreRandCmdMT->SetGuidance( << 372 " /random/setDirectoryName."); 334 "Directory of the status file should be se << 335 " /random/setDirectoryName."); << 336 restoreRandCmdMT->SetDefaultValue(false); 373 restoreRandCmdMT->SetDefaultValue(false); 337 restoreRandCmdMT->AvailableForStates(G4State << 374 restoreRandCmdMT->AvailableForStates(G4State_PreInit, G4State_Idle, >> 375 G4State_GeomClosed); 338 376 339 saveEachEventCmd = new G4UIcmdWithABool("/ra 377 saveEachEventCmd = new G4UIcmdWithABool("/random/saveEachEventFlag", this); 340 saveEachEventCmd->SetGuidance("Save random n << 378 saveEachEventCmd->SetGuidance( 341 saveEachEventCmd->SetGuidance("File name con << 379 "Save random number status at beginning of each event."); >> 380 saveEachEventCmd->SetGuidance( >> 381 "File name contains run and event numbers: runXXXevtYYY.rndm"); 342 saveEachEventCmd->SetParameterName("flag", t 382 saveEachEventCmd->SetParameterName("flag", true); 343 saveEachEventCmd->SetDefaultValue(true); 383 saveEachEventCmd->SetDefaultValue(true); 344 384 345 randEvtCmd = new G4UIcmdWithAnInteger("/run/ 385 randEvtCmd = new G4UIcmdWithAnInteger("/run/storeRndmStatToEvent", this); 346 randEvtCmd->SetGuidance("Flag to store rndm 386 randEvtCmd->SetGuidance("Flag to store rndm status to G4Event object."); 347 randEvtCmd->SetGuidance(" flag = 0 : not sto 387 randEvtCmd->SetGuidance(" flag = 0 : not store (default)"); 348 randEvtCmd->SetGuidance(" flag = 1 : status << 388 randEvtCmd->SetGuidance( >> 389 " flag = 1 : status before primary particle generation is stored"); 349 randEvtCmd->SetGuidance( 390 randEvtCmd->SetGuidance( 350 " flag = 2 : status before event processin 391 " flag = 2 : status before event processing (after primary " 351 "particle generation) is stored"); 392 "particle generation) is stored"); 352 randEvtCmd->SetGuidance(" flag = 3 : both ar 393 randEvtCmd->SetGuidance(" flag = 3 : both are stored"); 353 randEvtCmd->SetGuidance( 394 randEvtCmd->SetGuidance( 354 "Note: Some performance overhead may be se 395 "Note: Some performance overhead may be seen by storing rndm " 355 "status, in particular"); 396 "status, in particular"); 356 randEvtCmd->SetGuidance( 397 randEvtCmd->SetGuidance( 357 "for the case of simplest geometry and sma 398 "for the case of simplest geometry and small number of tracks per event."); 358 randEvtCmd->SetParameterName("flag", true); 399 randEvtCmd->SetParameterName("flag", true); 359 randEvtCmd->SetDefaultValue(0); 400 randEvtCmd->SetDefaultValue(0); 360 randEvtCmd->SetRange("flag>=0 && flag<=3"); 401 randEvtCmd->SetRange("flag>=0 && flag<=3"); 361 randEvtCmd->AvailableForStates(G4State_PreIn 402 randEvtCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 362 403 363 procUICmds = new G4UIcmdWithoutParameter("/r 404 procUICmds = new G4UIcmdWithoutParameter("/run/workersProcessCmds", this); 364 procUICmds->SetToBeBroadcasted(false); 405 procUICmds->SetToBeBroadcasted(false); 365 procUICmds->SetGuidance("Force workers to pr << 406 procUICmds->SetGuidance( >> 407 "Force workers to process current stack of UI commands."); 366 procUICmds->SetGuidance("This commands is me 408 procUICmds->SetGuidance("This commands is meaningful only in MT mode."); 367 procUICmds->AvailableForStates(G4State_PreIn << 409 procUICmds->AvailableForStates(G4State_PreInit, G4State_Idle, 368 << 410 G4State_GeomClosed); 369 trajMergeCmd = new G4UIcmdWithABool("/run/tr << 370 trajMergeCmd->SetGuidance("Merge trajectorie << 371 trajMergeCmd->SetGuidance("In sub-event para << 372 trajMergeCmd->SetGuidance("threads are not m << 373 trajMergeCmd->SetGuidance("due to the perfor << 374 trajMergeCmd->SetGuidance("This command enab << 375 trajMergeCmd->SetGuidance("/tracking/storeTr << 376 trajMergeCmd->SetGuidance("This command is v << 377 trajMergeCmd->AvailableForStates(G4State_Pre << 378 trajMergeCmd->SetParameterName("flag", true) << 379 trajMergeCmd->SetDefaultValue(true); << 380 trajMergeCmd->SetToBeBroadcasted(false); << 381 } 411 } 382 412 383 // ------------------------------------------- 413 // -------------------------------------------------------------------- 384 G4RunMessenger::~G4RunMessenger() 414 G4RunMessenger::~G4RunMessenger() 385 { 415 { >> 416 delete materialScanner; 386 delete beamOnCmd; 417 delete beamOnCmd; 387 delete verboseCmd; 418 delete verboseCmd; 388 delete printProgCmd; 419 delete printProgCmd; 389 delete nThreadsCmd; 420 delete nThreadsCmd; 390 delete maxThreadsCmd; 421 delete maxThreadsCmd; 391 delete pinAffinityCmd; 422 delete pinAffinityCmd; 392 delete evModCmd; 423 delete evModCmd; 393 delete optCmd; 424 delete optCmd; 394 delete dumpRegCmd; 425 delete dumpRegCmd; 395 delete dumpCoupleCmd; 426 delete dumpCoupleCmd; 396 delete brkBoECmd; 427 delete brkBoECmd; 397 delete brkEoECmd; 428 delete brkEoECmd; 398 delete abortCmd; 429 delete abortCmd; 399 delete abortEventCmd; 430 delete abortEventCmd; 400 delete initCmd; 431 delete initCmd; 401 delete geomCmd; 432 delete geomCmd; 402 delete geomRebCmd; 433 delete geomRebCmd; 403 delete physCmd; 434 delete physCmd; 404 delete randEvtCmd; 435 delete randEvtCmd; 405 delete constScoreCmd; 436 delete constScoreCmd; 406 delete procUICmds; 437 delete procUICmds; 407 delete trajMergeCmd; << 408 438 409 delete seedCmd; 439 delete seedCmd; 410 delete savingFlagCmd; 440 delete savingFlagCmd; 411 delete saveThisRunCmd; 441 delete saveThisRunCmd; 412 delete saveThisEventCmd; 442 delete saveThisEventCmd; 413 delete restoreRandCmd; 443 delete restoreRandCmd; 414 delete randomDirectory; 444 delete randomDirectory; 415 delete saveEachEventCmd; 445 delete saveEachEventCmd; 416 446 417 delete randDirCmd; 447 delete randDirCmd; 418 delete runDirectory; 448 delete runDirectory; 419 449 420 delete restoreRandCmdMT; 450 delete restoreRandCmdMT; 421 } 451 } 422 452 423 // ------------------------------------------- 453 // -------------------------------------------------------------------- 424 void G4RunMessenger::SetNewValue(G4UIcommand* 454 void G4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 425 { 455 { 426 if (command == beamOnCmd) { << 456 if(command == beamOnCmd) >> 457 { 427 G4int nev; 458 G4int nev; 428 G4int nst; 459 G4int nst; 429 const auto nv = (const char*)newValue; << 460 const char* nv = (const char*) newValue; 430 std::istringstream is(nv); 461 std::istringstream is(nv); 431 is >> nev >> macroFileName >> nst; 462 is >> nev >> macroFileName >> nst; 432 if (macroFileName == "***NULL***") { << 463 if(macroFileName == "***NULL***") >> 464 { 433 runManager->BeamOn(nev); 465 runManager->BeamOn(nev); 434 } 466 } 435 else { << 467 else >> 468 { 436 runManager->BeamOn(nev, macroFileName, n 469 runManager->BeamOn(nev, macroFileName, nst); 437 } 470 } 438 } 471 } 439 else if (command == verboseCmd) { << 472 else if(command == verboseCmd) >> 473 { 440 runManager->SetVerboseLevel(verboseCmd->Ge 474 runManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); 441 } 475 } 442 else if (command == printProgCmd) { << 476 else if(command == printProgCmd) >> 477 { 443 runManager->SetPrintProgress(printProgCmd- 478 runManager->SetPrintProgress(printProgCmd->GetNewIntValue(newValue)); 444 } 479 } 445 else if (command == nThreadsCmd) { << 480 else if(command == nThreadsCmd) >> 481 { 446 G4RunManager::RMType rmType = runManager-> 482 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 447 if (rmType == G4RunManager::masterRM) { << 483 if(rmType == G4RunManager::masterRM) >> 484 { 448 static_cast<G4MTRunManager*>(runManager) 485 static_cast<G4MTRunManager*>(runManager) 449 ->SetNumberOfThreads(nThreadsCmd->GetN 486 ->SetNumberOfThreads(nThreadsCmd->GetNewIntValue(newValue)); 450 } 487 } 451 else if (rmType == G4RunManager::sequentia << 488 else if(rmType == G4RunManager::sequentialRM) >> 489 { 452 G4cout << "*** /run/numberOfThreads comm 490 G4cout << "*** /run/numberOfThreads command is issued in sequential mode." 453 << "\nCommand is ignored." << G4e 491 << "\nCommand is ignored." << G4endl; 454 } 492 } 455 else { << 493 else >> 494 { 456 G4Exception("G4RunMessenger::ApplyNewCom 495 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0901", FatalException, 457 "/run/numberOfThreads comman 496 "/run/numberOfThreads command is issued to local thread."); 458 } 497 } 459 } 498 } 460 else if (command == maxThreadsCmd) { << 499 else if(command == maxThreadsCmd) >> 500 { 461 G4RunManager::RMType rmType = runManager-> 501 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 462 if (rmType == G4RunManager::masterRM) { << 502 if(rmType == G4RunManager::masterRM) >> 503 { 463 static_cast<G4MTRunManager*>(runManager) 504 static_cast<G4MTRunManager*>(runManager) 464 ->SetNumberOfThreads(G4Threading::G4Ge 505 ->SetNumberOfThreads(G4Threading::G4GetNumberOfCores()); 465 } 506 } 466 else if (rmType == G4RunManager::sequentia << 507 else if(rmType == G4RunManager::sequentialRM) >> 508 { 467 G4cout << "*** /run/useMaximumLogicalCor 509 G4cout << "*** /run/useMaximumLogicalCores command is issued in " 468 "sequential mode." 510 "sequential mode." 469 << "\nCommand is ignored." << G4e 511 << "\nCommand is ignored." << G4endl; 470 } 512 } 471 else { << 513 else 472 G4Exception("G4RunMessenger::ApplyNewCom << 514 { 473 "/run/useMaximumLogicalCores << 515 G4Exception( >> 516 "G4RunMessenger::ApplyNewCommand", "Run0901", FatalException, >> 517 "/run/useMaximumLogicalCores command is issued to local thread."); 474 } 518 } 475 } 519 } 476 else if (command == pinAffinityCmd) { << 520 else if(command == pinAffinityCmd) >> 521 { 477 G4RunManager::RMType rmType = runManager-> 522 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 478 if (rmType == G4RunManager::masterRM) { << 523 if(rmType == G4RunManager::masterRM) >> 524 { 479 static_cast<G4MTRunManager*>(runManager) 525 static_cast<G4MTRunManager*>(runManager) 480 ->SetPinAffinity(pinAffinityCmd->GetNe 526 ->SetPinAffinity(pinAffinityCmd->GetNewIntValue(newValue)); 481 } 527 } 482 else if (rmType == G4RunManager::sequentia << 528 else if(rmType == G4RunManager::sequentialRM) >> 529 { 483 G4cout << "*** /run/pinAffinity command 530 G4cout << "*** /run/pinAffinity command is issued in sequential mode." 484 << "\nCommand is ignored." << G4e 531 << "\nCommand is ignored." << G4endl; 485 } 532 } 486 else { << 533 else >> 534 { 487 G4Exception("G4RunMessenger::ApplyNewCom 535 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0901", FatalException, 488 "/run/pinAffinity command is 536 "/run/pinAffinity command is issued to local thread."); 489 } 537 } 490 } 538 } 491 else if (command == evModCmd) { << 539 else if(command == evModCmd) >> 540 { 492 G4RunManager::RMType rmType = runManager-> 541 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 493 if (rmType == G4RunManager::masterRM) { << 542 if(rmType == G4RunManager::masterRM) 494 G4int nevMod = 0; << 543 { 495 G4int sOnce = 0; << 544 G4int nevMod = 0; 496 const auto nv = (const char*)newValue; << 545 G4int sOnce = 0; >> 546 const char* nv = (const char*) newValue; 497 std::istringstream is(nv); 547 std::istringstream is(nv); 498 is >> nevMod >> sOnce; 548 is >> nevMod >> sOnce; 499 static_cast<G4MTRunManager*>(runManager) 549 static_cast<G4MTRunManager*>(runManager)->SetEventModulo(nevMod); 500 G4MTRunManager::SetSeedOncePerCommunicat 550 G4MTRunManager::SetSeedOncePerCommunication(sOnce); 501 } 551 } 502 else if (rmType == G4RunManager::sequentia << 552 else if(rmType == G4RunManager::sequentialRM) >> 553 { 503 G4cout << "*** /run/eventModulo command 554 G4cout << "*** /run/eventModulo command is issued in sequential mode." 504 << "\nCommand is ignored." << G4e 555 << "\nCommand is ignored." << G4endl; 505 } 556 } 506 else if (rmType == G4RunManager::subEventM << 557 else 507 G4cout << "*** /run/eventModulo command << 558 { 508 << "\nCommand is ignored." << G4e << 509 } << 510 else { << 511 G4Exception("G4RunMessenger::ApplyNewCom 559 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0902", FatalException, 512 "/run/eventModulo command is << 560 "/run/eventModulo command is issued to local thread."); 513 } 561 } 514 } 562 } 515 else if (command == dumpRegCmd) { << 563 else if(command == dumpRegCmd) 516 if (newValue == "**ALL**") { << 564 { >> 565 if(newValue == "**ALL**") >> 566 { 517 runManager->DumpRegion(); 567 runManager->DumpRegion(); 518 } 568 } 519 else { << 569 else >> 570 { 520 runManager->DumpRegion(newValue); 571 runManager->DumpRegion(newValue); 521 } 572 } 522 } 573 } 523 else if (command == dumpCoupleCmd) { << 574 else if(command == dumpCoupleCmd) >> 575 { 524 G4ProductionCutsTable::GetProductionCutsTa 576 G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples(); 525 } 577 } 526 else if (command == optCmd) { << 578 else if(command == optCmd) >> 579 { 527 runManager->SetGeometryToBeOptimized(optCm 580 runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue)); 528 } 581 } 529 else if (command == brkBoECmd) { << 582 else if(command == brkBoECmd) 530 G4UImanager::GetUIpointer()->SetPauseAtBeg << 583 { >> 584 G4UImanager::GetUIpointer()->SetPauseAtBeginOfEvent( >> 585 brkBoECmd->GetNewBoolValue(newValue)); >> 586 } >> 587 else if(command == brkEoECmd) >> 588 { >> 589 G4UImanager::GetUIpointer()->SetPauseAtEndOfEvent( >> 590 brkEoECmd->GetNewBoolValue(newValue)); 531 } 591 } 532 else if (command == brkEoECmd) { << 592 else if(command == abortCmd) 533 G4UImanager::GetUIpointer()->SetPauseAtEnd << 593 { 534 } << 535 else if (command == abortCmd) { << 536 runManager->AbortRun(abortCmd->GetNewBoolV 594 runManager->AbortRun(abortCmd->GetNewBoolValue(newValue)); 537 } 595 } 538 else if (command == abortEventCmd) { << 596 else if(command == abortEventCmd) >> 597 { 539 runManager->AbortEvent(); 598 runManager->AbortEvent(); 540 } 599 } 541 else if (command == initCmd) { << 600 else if(command == initCmd) >> 601 { 542 runManager->Initialize(); 602 runManager->Initialize(); 543 } 603 } 544 else if (command == geomCmd) { << 604 else if(command == geomCmd) >> 605 { 545 runManager->GeometryHasBeenModified(false) 606 runManager->GeometryHasBeenModified(false); 546 } 607 } 547 else if (command == geomRebCmd) { << 608 else if(command == geomRebCmd) 548 runManager->ReinitializeGeometry(geomRebCm << 609 { >> 610 runManager->ReinitializeGeometry(geomRebCmd->GetNewBoolValue(newValue), >> 611 false); 549 } 612 } 550 else if (command == physCmd) { << 613 else if(command == physCmd) >> 614 { 551 runManager->PhysicsHasBeenModified(); 615 runManager->PhysicsHasBeenModified(); 552 } 616 } 553 else if (command == seedCmd) { << 617 else if(command == seedCmd) >> 618 { 554 G4Tokenizer next(newValue); 619 G4Tokenizer next(newValue); 555 G4int idx = 0; 620 G4int idx = 0; 556 G4long seeds[100]; 621 G4long seeds[100]; 557 G4String vl; 622 G4String vl; 558 while (!(vl = next()).empty()) { << 623 while(!(vl = next()).empty()) >> 624 { 559 seeds[idx] = StoL(vl); 625 seeds[idx] = StoL(vl); 560 ++idx; 626 ++idx; 561 } 627 } 562 if (idx < 2) { << 628 if(idx < 2) >> 629 { 563 G4cerr << "/random/setSeeds should have 630 G4cerr << "/random/setSeeds should have at least two values. " 564 "Command ignored." 631 "Command ignored." 565 << G4endl; 632 << G4endl; 566 } 633 } 567 else { << 634 else >> 635 { 568 seeds[idx] = 0; 636 seeds[idx] = 0; 569 G4Random::setTheSeeds(seeds); 637 G4Random::setTheSeeds(seeds); 570 } 638 } 571 } 639 } 572 else if (command == randDirCmd) { << 640 else if(command == randDirCmd) >> 641 { 573 runManager->SetRandomNumberStoreDir(newVal 642 runManager->SetRandomNumberStoreDir(newValue); 574 } 643 } 575 else if (command == savingFlagCmd) { << 644 else if(command == savingFlagCmd) >> 645 { 576 runManager->SetRandomNumberStore(savingFla 646 runManager->SetRandomNumberStore(savingFlagCmd->GetNewBoolValue(newValue)); 577 } 647 } 578 else if (command == saveThisRunCmd) { << 648 else if(command == saveThisRunCmd) >> 649 { 579 runManager->rndmSaveThisRun(); 650 runManager->rndmSaveThisRun(); 580 } 651 } 581 else if (command == saveThisEventCmd) { << 652 else if(command == saveThisEventCmd) >> 653 { 582 runManager->rndmSaveThisEvent(); 654 runManager->rndmSaveThisEvent(); 583 } 655 } 584 else if (command == restoreRandCmd) { << 656 else if(command == restoreRandCmd) >> 657 { 585 runManager->RestoreRandomNumberStatus(newV 658 runManager->RestoreRandomNumberStatus(newValue); 586 } 659 } 587 else if (command == randEvtCmd) { << 660 else if(command == randEvtCmd) 588 runManager->StoreRandomNumberStatusToG4Eve << 661 { 589 } << 662 runManager->StoreRandomNumberStatusToG4Event( 590 else if (command == saveEachEventCmd) { << 663 randEvtCmd->GetNewIntValue(newValue)); 591 runManager->SetRandomNumberStorePerEvent(s << 664 } >> 665 else if(command == saveEachEventCmd) >> 666 { >> 667 runManager->SetRandomNumberStorePerEvent( >> 668 saveEachEventCmd->GetNewBoolValue(newValue)); 592 } 669 } 593 else if (command == constScoreCmd) { << 670 else if(command == constScoreCmd) >> 671 { 594 runManager->ConstructScoringWorlds(); 672 runManager->ConstructScoringWorlds(); 595 } 673 } 596 else if (command == restoreRandCmdMT) { << 674 else if(command == restoreRandCmdMT) 597 runManager->RestoreRndmEachEvent(restoreRa << 675 { >> 676 runManager->RestoreRndmEachEvent( >> 677 restoreRandCmdMT->GetNewBoolValue(newValue)); 598 } 678 } 599 else if (command == procUICmds) { << 679 else if(command == procUICmds) >> 680 { 600 G4RunManager::RMType rmType = runManager-> 681 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 601 if (rmType == G4RunManager::masterRM) { << 682 if(rmType == G4RunManager::masterRM) >> 683 { 602 auto rm = dynamic_cast<G4MTRunManager*>( 684 auto rm = dynamic_cast<G4MTRunManager*>(runManager); 603 if (rm != nullptr) { << 685 if(rm != nullptr) >> 686 { 604 rm->RequestWorkersProcessCommandsStack 687 rm->RequestWorkersProcessCommandsStack(); 605 } 688 } 606 else { << 689 else >> 690 { 607 G4Exception("G4RunManager::ApplyNewCom 691 G4Exception("G4RunManager::ApplyNewCommand", "Run0128", FatalException, 608 "/run/workersProcessCmds c 692 "/run/workersProcessCmds command issued on a " 609 "non-G4MTRunManager class 693 "non-G4MTRunManager class instance."); 610 } 694 } 611 } 695 } 612 else if (rmType == G4RunManager::sequentia << 696 else if(rmType == G4RunManager::sequentialRM) 613 G4cout << "*** /run/workersProcessCmds c << 697 { 614 << "\nCommand is ignored." << G4e << 698 G4cout >> 699 << "*** /run/workersProcessCmds command is issued in sequential mode." >> 700 << "\nCommand is ignored." << G4endl; 615 } 701 } 616 else { << 702 else >> 703 { 617 G4Exception("G4RunMessenger::ApplyNewCom 704 G4Exception("G4RunMessenger::ApplyNewCommand", "Run0129", FatalException, 618 "/run/workersProcessCmds com 705 "/run/workersProcessCmds command is issued to local thread."); 619 } 706 } 620 } 707 } 621 else if (command == trajMergeCmd) { << 622 G4RunManager::RMType rmType = runManager-> << 623 if (rmType == G4RunManager::subEventMaster << 624 auto rm = dynamic_cast<G4SubEvtRunManage << 625 if (rm != nullptr) { << 626 rm->TrajectoriesToBeMerged(trajMergeCm << 627 } << 628 else { << 629 G4ExceptionDescription ed; << 630 ed << "/run/trajectoriesToBeMerged com << 631 << "instance that is not G4SubEvtRu << 632 G4Exception("G4RunManager::ApplyNewCom << 633 } << 634 } << 635 else { << 636 G4cout << "*** /run/trajectoriesToBeMerg << 637 << "class instance that is not G4 << 638 << "\nCommand is ignored." << G4e << 639 } << 640 } << 641 } 708 } 642 709 643 // ------------------------------------------- 710 // -------------------------------------------------------------------- 644 G4String G4RunMessenger::GetCurrentValue(G4UIc 711 G4String G4RunMessenger::GetCurrentValue(G4UIcommand* command) 645 { 712 { 646 G4String cv; 713 G4String cv; 647 714 648 if (command == verboseCmd) { << 715 if(command == verboseCmd) >> 716 { 649 cv = verboseCmd->ConvertToString(runManage 717 cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel()); 650 } 718 } 651 else if (command == printProgCmd) { << 719 else if(command == printProgCmd) >> 720 { 652 cv = printProgCmd->ConvertToString(runMana 721 cv = printProgCmd->ConvertToString(runManager->GetPrintProgress()); 653 } 722 } 654 else if (command == randDirCmd) { << 723 else if(command == randDirCmd) >> 724 { 655 cv = runManager->GetRandomNumberStoreDir() 725 cv = runManager->GetRandomNumberStoreDir(); 656 } 726 } 657 else if (command == randEvtCmd) { << 727 else if(command == randEvtCmd) 658 cv = randEvtCmd->ConvertToString(runManage << 728 { >> 729 cv = randEvtCmd->ConvertToString( >> 730 runManager->GetFlagRandomNumberStatusToG4Event()); 659 } 731 } 660 else if (command == nThreadsCmd) { << 732 else if(command == nThreadsCmd) >> 733 { 661 G4RunManager::RMType rmType = runManager-> 734 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 662 if (rmType == G4RunManager::masterRM) { << 735 if(rmType == G4RunManager::masterRM) >> 736 { 663 cv = nThreadsCmd->ConvertToString( 737 cv = nThreadsCmd->ConvertToString( 664 static_cast<G4MTRunManager*>(runManage 738 static_cast<G4MTRunManager*>(runManager)->GetNumberOfThreads()); 665 } 739 } 666 else if (rmType == G4RunManager::sequentia << 740 else if(rmType == G4RunManager::sequentialRM) >> 741 { 667 cv = "0"; 742 cv = "0"; 668 } 743 } 669 } 744 } 670 else if (command == evModCmd) { << 745 else if(command == evModCmd) >> 746 { 671 G4RunManager::RMType rmType = runManager-> 747 G4RunManager::RMType rmType = runManager->GetRunManagerType(); 672 if (rmType == G4RunManager::masterRM) { << 748 if(rmType == G4RunManager::masterRM) 673 cv = evModCmd->ConvertToString(static_ca << 749 { 674 + " " + evModCmd->ConvertToString(G << 750 cv = 675 } << 751 evModCmd->ConvertToString( 676 else if (rmType == G4RunManager::sequentia << 752 static_cast<G4MTRunManager*>(runManager)->GetEventModulo()) + 677 G4cout << "*** /run/eventModulo command << 753 " " + >> 754 evModCmd->ConvertToString(G4MTRunManager::SeedOncePerCommunication()); >> 755 } >> 756 else if(rmType == G4RunManager::sequentialRM) >> 757 { >> 758 G4cout << "*** /run/eventModulo command is valid only in MT mode." >> 759 << G4endl; 678 } 760 } 679 } 761 } 680 762 681 return cv; 763 return cv; 682 } 764 } 683 765