File indexing completed on 2025-12-18 09:32:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "F04RunActionMessenger.hh"
0032
0033 #include "F04RunAction.hh"
0034
0035 #include "G4UIcmdWithABool.hh"
0036 #include "G4UIcmdWithAString.hh"
0037 #include "G4UIcmdWithAnInteger.hh"
0038 #include "G4UIdirectory.hh"
0039 #include "Randomize.hh"
0040 #include "globals.hh"
0041
0042
0043
0044 F04RunActionMessenger::F04RunActionMessenger(F04RunAction* runAction) : fRunAction(runAction)
0045 {
0046 fRndmDir = new G4UIdirectory("/rndm/");
0047 fRndmDir->SetGuidance("Rndm status control.");
0048
0049 fRndmSaveCmd = new G4UIcmdWithAnInteger("/rndm/save", this);
0050 fRndmSaveCmd->SetGuidance("set frequency to save rndm status on external files.");
0051 fRndmSaveCmd->SetGuidance("freq = 0 not saved");
0052 fRndmSaveCmd->SetGuidance("freq > 0 saved on: beginOfRun.rndm");
0053 fRndmSaveCmd->SetGuidance("freq = 1 saved on: endOfRun.rndm");
0054 fRndmSaveCmd->SetGuidance("freq = 2 saved on: endOfEvent.rndm");
0055 fRndmSaveCmd->SetParameterName("frequency", false);
0056 fRndmSaveCmd->SetRange("frequency>=0 && frequency<=2");
0057 fRndmSaveCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0058
0059 fRndmReadCmd = new G4UIcmdWithAString("/rndm/read", this);
0060 fRndmReadCmd->SetGuidance("get rndm status from an external file.");
0061 fRndmReadCmd->SetParameterName("fileName", true);
0062 fRndmReadCmd->SetDefaultValue("beginOfRun.rndm");
0063 fRndmReadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0064
0065 fSetAutoSeedCmd = new G4UIcmdWithABool("/rndm/autoSeed", this);
0066 fSetAutoSeedCmd->SetGuidance("Switch on/off time-based random seeds");
0067 fSetAutoSeedCmd->SetGuidance(" true: run seeds determined by system time");
0068 fSetAutoSeedCmd->SetGuidance("false: use command 'random/resetEngineFrom'");
0069 fSetAutoSeedCmd->SetGuidance("Default = false");
0070 fSetAutoSeedCmd->SetParameterName("autoSeed", false);
0071 fSetAutoSeedCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 }
0073
0074
0075
0076 F04RunActionMessenger::~F04RunActionMessenger()
0077 {
0078 delete fRndmDir;
0079 delete fRndmSaveCmd;
0080 delete fRndmReadCmd;
0081 delete fSetAutoSeedCmd;
0082 }
0083
0084
0085
0086 void F04RunActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0087 {
0088 if (command == fRndmSaveCmd) fRunAction->SetRndmFreq(fRndmSaveCmd->GetNewIntValue(newValue));
0089
0090 if (command == fRndmReadCmd) {
0091 G4cout << "\n---> rndm status restored from file: " << newValue << G4endl;
0092 G4Random::restoreEngineStatus(newValue);
0093 G4Random::showEngineStatus();
0094 }
0095
0096 if (command == fSetAutoSeedCmd)
0097 fRunAction->SetAutoSeed(fSetAutoSeedCmd->GetNewBoolValue(newValue));
0098 }