Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4RunMessenger Class Reference

#include <G4RunMessenger.hh>

+ Inheritance diagram for G4RunMessenger:

Public Member Functions

 G4RunMessenger (G4RunManager *runMgr)
 
 ~G4RunMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Detailed Description

Definition at line 68 of file G4RunMessenger.hh.

Constructor & Destructor Documentation

◆ G4RunMessenger()

G4RunMessenger::G4RunMessenger ( G4RunManager runMgr)

Definition at line 47 of file G4RunMessenger.cc.

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("If G4 kernel is not initialized, it will be initialized.");
60 beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
61 beamOnCmd->SetGuidance("The second and third arguments can be used for");
62 beamOnCmd->SetGuidance("executing a macro file at the end of each event.");
63 beamOnCmd->SetGuidance("If the second argument, i.e. name of the macro");
64 beamOnCmd->SetGuidance("file, is given but the third argument is not,");
65 beamOnCmd->SetGuidance("the macro file will be executed for all of the");
66 beamOnCmd->SetGuidance("event.");
67 beamOnCmd->SetGuidance("If the third argument (nSelect) is given, the");
68 beamOnCmd->SetGuidance("macro file will be executed only for the first");
69 beamOnCmd->SetGuidance("nSelect events.");
71 G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
72 p1->SetDefaultValue(1);
73 p1->SetParameterRange("numberOfEvent >= 0");
74 beamOnCmd->SetParameter(p1);
75 G4UIparameter* p2 = new G4UIparameter("macroFile",'s',true);
76 p2->SetDefaultValue("***NULL***");
77 beamOnCmd->SetParameter(p2);
78 G4UIparameter* p3 = new G4UIparameter("nSelect",'i',true);
79 p3->SetDefaultValue(-1);
80 p3->SetParameterRange("nSelect>=-1");
81 beamOnCmd->SetParameter(p3);
82
83 verboseCmd = new G4UIcmdWithAnInteger("/run/verbose",this);
84 verboseCmd->SetGuidance("Set the Verbose level of G4RunManager.");
85 verboseCmd->SetGuidance(" 0 : Silent (default)");
86 verboseCmd->SetGuidance(" 1 : Display main topics");
87 verboseCmd->SetGuidance(" 2 : Display main topics and run summary");
88 verboseCmd->SetParameterName("level",true);
89 verboseCmd->SetDefaultValue(0);
90 verboseCmd->SetRange("level >=0 && level <=2");
91
92 dumpRegCmd = new G4UIcmdWithAString("/run/dumpRegion",this);
93 dumpRegCmd->SetGuidance("Dump region information.");
94 dumpRegCmd->SetGuidance("In case name of a region is not given, all regions will be displayed.");
95 dumpRegCmd->SetParameterName("regionName", true);
96 dumpRegCmd->SetDefaultValue("**ALL**");
98
99 dumpCoupleCmd = new G4UIcmdWithoutParameter("/run/dumpCouples",this);
100 dumpCoupleCmd->SetGuidance("Dump material-cuts-couple information.");
101 dumpCoupleCmd->SetGuidance("Note that material-cuts-couple information is updated");
102 dumpCoupleCmd->SetGuidance("after BeamOn has started.");
103 dumpCoupleCmd->AvailableForStates(G4State_Idle);
104
105 optCmd = new G4UIcmdWithABool("/run/optimizeGeometry",this);
106 optCmd->SetGuidance("Set the optimization flag for geometry.");
107 optCmd->SetGuidance("If it is set to TRUE, G4GeometryManager will optimize");
108 optCmd->SetGuidance("the geometry definitions.");
109 optCmd->SetGuidance("GEANT4 is initialized with this flag as TRUE.");
110 optCmd->SetParameterName("optimizeFlag",true);
111 optCmd->SetDefaultValue(true);
113
114 brkBoECmd = new G4UIcmdWithABool("/run/breakAtBeginOfEvent",this);
115 brkBoECmd->SetGuidance("Set a break point at the begining of every event.");
116 brkBoECmd->SetParameterName("flag",true);
117 brkBoECmd->SetDefaultValue(true);
118
119 brkEoECmd = new G4UIcmdWithABool("/run/breakAtEndOfEvent",this);
120 brkEoECmd->SetGuidance("Set a break point at the end of every event.");
121 brkEoECmd->SetParameterName("flag",true);
122 brkEoECmd->SetDefaultValue(true);
123
124 abortCmd = new G4UIcmdWithABool("/run/abort",this);
125 abortCmd->SetGuidance("Abort current run processing.");
126 abortCmd->SetGuidance("If softAbort is false (default), currently processing event will be immediately aborted,");
127 abortCmd->SetGuidance("while softAbort is true, abortion occurs after processing the current event.");
129 abortCmd->SetParameterName("softAbort",true);
130 abortCmd->SetDefaultValue(false);
131
132 abortEventCmd = new G4UIcmdWithoutParameter("/run/abortCurrentEvent",this);
133 abortEventCmd->SetGuidance("Abort currently processing event.");
135
136 geomCmd = new G4UIcmdWithoutParameter("/run/geometryModified",this);
137 geomCmd->SetGuidance("Force geometry to be closed again.");
138 geomCmd->SetGuidance("This command must be applied");
139 geomCmd->SetGuidance(" if geometry has been modified after the");
140 geomCmd->SetGuidance(" first initialization (or BeamOn).");
142
143 physCmd = new G4UIcmdWithoutParameter("/run/physicsModified",this);
144 physCmd->SetGuidance("Force all physics tables recalculated again.");
145 physCmd->SetGuidance("This command must be applied");
146 physCmd->SetGuidance(" if physics process has been modified after the");
147 physCmd->SetGuidance(" first initialization (or BeamOn).");
149
150 cutCmd = new G4UIcmdWithoutParameter("/run/cutoffModified",this);
151 cutCmd->SetGuidance("/run/cutoffModified becomes obsolete.");
152 cutCmd->SetGuidance("It is safe to remove invoking this command.");
153
154 constScoreCmd = new G4UIcmdWithoutParameter("/run/constructScoringWorlds",this);
155 constScoreCmd->SetGuidance("Constrct scoring parallel world(s) if defined.");
156 constScoreCmd->SetGuidance("This command is not mandatory, but automatically called when a run starts.");
157 constScoreCmd->SetGuidance("But the user may use this to visualize the scoring world(s) before a run to start.");
158 constScoreCmd->AvailableForStates(G4State_Idle);
159
160 materialScanner = new G4MaterialScanner();
161
162 randomDirectory = new G4UIdirectory("/random/");
163 randomDirectory->SetGuidance("Random number status control commands.");
164
165 seedCmd = new G4UIcmdWithAString("/random/setSeeds",this);
166 seedCmd->SetGuidance("Initialize the random number generator with integer seed stream.");
167 seedCmd->SetGuidance("Number of integers should be more than 1.");
168 seedCmd->SetGuidance("Actual number of integers to be used depends on the individual random number engine.");
169 seedCmd->SetParameterName("IntArray",false);
171
172 randDirCmd = new G4UIcmdWithAString("/random/setDirectoryName",this);
173 randDirCmd->SetGuidance("Define the directory name of the rndm status files.");
174 randDirCmd->SetGuidance("Directory will be created if it does not exist.");
175 randDirCmd->SetParameterName("fileName",true);
176 randDirCmd->SetDefaultValue("./");
178
179 savingFlagCmd = new G4UIcmdWithABool("/random/setSavingFlag",this);
180 savingFlagCmd->SetGuidance("The randomNumberStatus will be saved at :");
181 savingFlagCmd->SetGuidance("begining of run (currentRun.rndm) and "
182 "begining of event (currentEvent.rndm) ");
183 savingFlagCmd->SetParameterName("flag",true);
184 savingFlagCmd->SetDefaultValue(true);
185
186 saveThisRunCmd = new G4UIcmdWithoutParameter("/random/saveThisRun",this);
187 saveThisRunCmd->SetGuidance("copy currentRun.rndm to runXXX.rndm");
189
190 saveThisEventCmd = new G4UIcmdWithoutParameter("/random/saveThisEvent",this);
191 saveThisEventCmd->SetGuidance("copy currentEvent.rndm to runXXXevtYYY.rndm");
192 saveThisEventCmd->AvailableForStates(G4State_EventProc);
193
194 restoreRandCmd = new G4UIcmdWithAString("/random/resetEngineFrom",this);
195 restoreRandCmd->SetGuidance("Reset the status of the rndm engine from a file.");
196 restoreRandCmd->SetGuidance("See CLHEP manual for detail.");
197 restoreRandCmd->SetGuidance("The engine status must be stored beforehand.");
198 restoreRandCmd->SetGuidance("Directory of the status file should be set by"
199 " /random/setDirectoryName.");
200 restoreRandCmd->SetParameterName("fileName",true);
201 restoreRandCmd->SetDefaultValue("currentRun.rndm");
203
204 randEvtCmd = new G4UIcmdWithAnInteger("/run/storeRndmStatToEvent",this);
205 randEvtCmd->SetGuidance("Flag to store rndm status to G4Event object.");
206 randEvtCmd->SetGuidance(" flag = 0 : not store (default)");
207 randEvtCmd->SetGuidance(" flag = 1 : status before primary particle generation is stored");
208 randEvtCmd->SetGuidance(" flag = 2 : status before event processing (after primary particle generation) is stored");
209 randEvtCmd->SetGuidance(" flag = 3 : both are stored");
210 randEvtCmd->SetGuidance("Note: Some performance overhead may be seen by storing rndm status, in particular");
211 randEvtCmd->SetGuidance("for the case of simplest geometry and small number of tracks per event.");
212 randEvtCmd->SetParameterName("flag",true);
213 randEvtCmd->SetDefaultValue(0);
214 randEvtCmd->SetRange("flag>=0 && flag<3");
216
217 //old commands for the rndm engine status handling
218 //
219 randDirOld = new G4UIcmdWithAString("/run/randomNumberStatusDirectory",this);
220 randDirOld->SetGuidance("Define the directory name of the rndm status files.");
221 randDirOld->SetGuidance("Directory must be creates before storing the files.");
222 randDirOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory");
223 randDirOld->SetParameterName("fileName",true);
224 randDirOld->SetDefaultValue("./");
226
227 storeRandOld = new G4UIcmdWithAnInteger("/run/storeRandomNumberStatus",this);
228 storeRandOld->SetGuidance("The randomNumberStatus will be saved at :");
229 storeRandOld->SetGuidance("begining of run (currentRun.rndm) and "
230 "begining of event (currentEvent.rndm) ");
231 storeRandOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory");
232 storeRandOld->SetParameterName("flag",true);
233 storeRandOld->SetDefaultValue(1);
234
235 restoreRandOld = new G4UIcmdWithAString("/run/restoreRandomNumberStatus",this);
236 restoreRandOld->SetGuidance("Reset the status of the rndm engine from a file.");
237 restoreRandOld->SetGuidance("See CLHEP manual for detail.");
238 restoreRandOld->SetGuidance("The engine status must be stored beforehand.");
239 restoreRandOld->SetGuidance("Directory of the status file should be set by"
240 " /random/setDirectoryName.");
241 restoreRandOld->SetGuidance("OBSOLETE --- Please use commands in /random/ directory");
242 restoreRandOld->SetParameterName("fileName",true);
243 restoreRandOld->SetDefaultValue("currentRun.rndm");
245}
@ G4State_EventProc
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
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)
void SetDefaultValue(G4int defVal)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
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:219
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)

◆ ~G4RunMessenger()

G4RunMessenger::~G4RunMessenger ( )

Definition at line 247 of file G4RunMessenger.cc.

248{
249 delete materialScanner;
250 delete beamOnCmd;
251 delete verboseCmd;
252 delete optCmd;
253 delete dumpRegCmd;
254 delete dumpCoupleCmd;
255 delete brkBoECmd;
256 delete brkEoECmd;
257 delete abortCmd;
258 delete abortEventCmd;
259 delete initCmd;
260 delete geomCmd;
261 delete physCmd;
262 delete cutCmd;
263 delete randEvtCmd;
264 delete randDirOld; delete storeRandOld; delete restoreRandOld;
265 delete constScoreCmd;
266 delete runDirectory;
267
268 delete randDirCmd;
269 delete seedCmd;
270 delete savingFlagCmd;
271 delete saveThisRunCmd;
272 delete saveThisEventCmd;
273 delete restoreRandCmd;
274 delete randomDirectory;
275}

Member Function Documentation

◆ GetCurrentValue()

G4String G4RunMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 375 of file G4RunMessenger.cc.

376{
377 G4String cv;
378
379 if( command==verboseCmd )
380 { cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel()); }
381 else if( command==randDirCmd )
382 { cv = runManager->GetRandomNumberStoreDir(); }
383 else if( command==randEvtCmd )
384 { cv = randEvtCmd->ConvertToString(runManager->GetFlagRandomNumberStatusToG4Event()); }
385
386 return cv;
387}
const G4String & GetRandomNumberStoreDir() const
G4int GetFlagRandomNumberStatusToG4Event() const
G4int GetVerboseLevel() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349

◆ SetNewValue()

void G4RunMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 277 of file G4RunMessenger.cc.

278{
279 if( command==beamOnCmd )
280 {
281 G4int nev;
282 G4int nst;
283 const char* nv = (const char*)newValue;
284 std::istringstream is(nv);
285 is >> nev >> macroFileName >> nst;
286 if(macroFileName=="***NULL***")
287 { runManager->BeamOn(nev); }
288 else
289 { runManager->BeamOn(nev,macroFileName,nst); }
290 }
291 else if( command==verboseCmd )
292 { runManager->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); }
293 else if( command==dumpRegCmd )
294 {
295 if(newValue=="**ALL**")
296 { runManager->DumpRegion(); }
297 else
298 { runManager->DumpRegion(newValue); }
299 }
300 else if( command==dumpCoupleCmd)
301 {
303 }
304 else if( command==optCmd )
305 { runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue)); }
306 else if( command==brkBoECmd )
308 else if( command==brkEoECmd )
310 else if( command==abortCmd )
311 { runManager->AbortRun(abortCmd->GetNewBoolValue(newValue)); }
312 else if( command==abortEventCmd )
313 { runManager->AbortEvent(); }
314 else if( command==initCmd )
315 { runManager->Initialize(); }
316 else if( command==geomCmd )
317 { runManager->GeometryHasBeenModified(); }
318 else if( command==physCmd )
319 { runManager->PhysicsHasBeenModified(); }
320 else if( command==cutCmd )
321 { runManager->CutOffHasBeenModified(); }
322
323 else if( command==seedCmd )
324 {
325 G4Tokenizer next(newValue);
326 G4int idx=0;
327 long seeds[100];
328 G4String vl;
329 while(!(vl=next()).isNull())
330 { seeds[idx] = (long)(StoI(vl)); idx++; }
331 if(idx<2)
332 { G4cerr << "/random/setSeeds should have at least two integers. Command ignored." << G4endl; }
333 else
334 {
335 seeds[idx] = 0;
337 }
338 }
339 else if( command==randDirCmd )
340 { runManager->SetRandomNumberStoreDir(newValue); }
341 else if( command==savingFlagCmd )
342 { runManager->SetRandomNumberStore(savingFlagCmd->GetNewBoolValue(newValue)); }
343 else if( command==saveThisRunCmd )
344 { runManager->rndmSaveThisRun(); }
345 else if( command==saveThisEventCmd )
346 { runManager->rndmSaveThisEvent(); }
347 else if( command==restoreRandCmd )
348 { runManager->RestoreRandomNumberStatus(newValue); }
349 else if( command==randEvtCmd )
350 { runManager->StoreRandomNumberStatusToG4Event(randEvtCmd->GetNewIntValue(newValue)); }
351
352 else if( command==randDirOld )
353 {G4cout << "warning: deprecated command. Use /random/setDirectoryName"
354 << G4endl;
355 // runManager->SetRandomNumberStoreDir(newValue);
356 }
357 else if( command==storeRandOld )
358 {G4cout << "warning: deprecated command. Use /random/setSavingFlag"
359 << G4endl;
360 // G4int frequency = storeRandOld->GetNewIntValue(newValue);
361 // G4bool flag = false;
362 // if(frequency != 0) flag = true;
363 // runManager->SetRandomNumberStore(flag);
364 }
365 else if( command==restoreRandOld )
366 {G4cout << "warning: deprecated command. Use /random/resetEngineFrom"
367 << G4endl;
368 // runManager->RestoreRandomNumberStatus(newValue);
369 }
370 else if( command==constScoreCmd )
371 { runManager->ConstructScoringWorlds(); }
372
373}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
static void setTheSeeds(const long *seeds, int aux=-1)
Definition: Random.cc:141
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 SetRandomNumberStoreDir(const G4String &dir)
virtual void rndmSaveThisEvent()
virtual void AbortEvent()
virtual void rndmSaveThisRun()
void PhysicsHasBeenModified()
void GeometryHasBeenModified()
void SetVerboseLevel(G4int vl)
void SetGeometryToBeOptimized(G4bool vl)
void StoreRandomNumberStatusToG4Event(G4int vl)
void CutOffHasBeenModified()
void SetRandomNumberStore(G4bool flag)
void DumpRegion(const G4String &rname) const
void ConstructScoringWorlds()
static G4bool GetNewBoolValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
void SetPauseAtBeginOfEvent(G4bool vl)
Definition: G4UImanager.hh:183
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
void SetPauseAtEndOfEvent(G4bool vl)
Definition: G4UImanager.hh:187
G4int StoI(G4String s)

The documentation for this class was generated from the following files: