EDepSimUserRunActionMessenger.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////
2 // $Id: EDepSim::UserRunActionMessenger.cc,v 1.7 2011/07/19 20:57:43 mcgrew Exp $
3 //
6 #include "EDepSimException.hh"
7 
8 #include <G4UIdirectory.hh>
9 #include <G4UIcmdWithoutParameter.hh>
10 #include <G4UIcmdWithAnInteger.hh>
11 #include <G4Timer.hh>
12 
13 #include <EDepSimLog.hh>
14 
17  : fUserRunAction(rdm) {
18 
19  fDir = new G4UIdirectory("/edep/random/");
20  fDir->SetGuidance("Control of the random seed number.");
21 
23  = new G4UIcmdWithAnInteger("/edep/random/randomSeed",this);
24  fRandomSeedCmd->SetGuidance("Sets the random number generator seed"
25  " using a single integer.");
26 
28  = new G4UIcmdWithoutParameter("/edep/random/timeRandomSeed",this);
29  fTimeRandomSeedCmd->SetGuidance("Sets the random number generator seed"
30  " using the system time.");
31 
33  = new G4UIcmdWithoutParameter("/edep/random/showRandomSeed",this);
34  fShowRandomSeedCmd->SetGuidance("Show the random number seed.");
35 
37  = new G4UIcmdWithAnInteger("/edep/runId",this);
38  fDetSimRunIdCmd->SetGuidance("This is the first run id that will be used by"
39  " GEANT. GEANT will automatically increment"
40  " the run id every time it starts a new"
41  " internal run so care must be taken if you"
42  " depend on this to pass-through the run id.");
43 
45  = new G4UIcmdWithAnInteger("/edep/subrunId",this);
46  fDetSimSubrunIdCmd->SetGuidance("Set the sub run context field for"
47  " documentation purposes. This has no"
48  " internal meaning.");
49 }
50 
52  delete fDir;
53  delete fRandomSeedCmd;
54  delete fTimeRandomSeedCmd;
55  delete fShowRandomSeedCmd;
56  delete fDetSimRunIdCmd;
57  delete fDetSimSubrunIdCmd;
58 }
59 
61  G4String newValue) {
62  if (command == fRandomSeedCmd) {
63  long seed = fRandomSeedCmd->GetNewIntValue(newValue);
64  fUserRunAction->SetSeed(seed);
65  }
66  else if (command == fTimeRandomSeedCmd) {
68  }
69  else if (command == fShowRandomSeedCmd) {
70  long seed = fUserRunAction->GetSeed();
71  EDepSimLog("### Random number seed: " << seed);
72  }
73  else if (command == fDetSimRunIdCmd) {
74  int runId = fDetSimRunIdCmd->GetNewIntValue(newValue);
76  }
77  else if (command == fDetSimSubrunIdCmd) {
78  int subrunId = fDetSimSubrunIdCmd->GetNewIntValue(newValue);
80  }
81  else {
82  EDepSimThrow("EDepSim::UserRunActionMessenger:: Unimplemented command");
83  }
84 }
85 
87  return fDir->GetCommandPath();
88 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
G4String GetPath()
Get the base directory for the messenger commands.
int command
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
void SetTimeSeed()
Build a seed for the generator based on the system time.
void SetNewValue(G4UIcommand *, G4String)
Handle messages from the UI processor.
UserRunActionMessenger(EDepSim::UserRunAction *)
long GetSeed(void) const
Get the seed that started the low level random generator.