7 #include "lcdd/util/StringUtil.hh"
10 #include "G4UIcommand.hh"
11 #include "G4UIdirectory.hh"
12 #include "G4UIcmdWithAnInteger.hh"
13 #include "G4UIcmdWithADoubleAndUnit.hh"
14 #include "G4UIcmdWithADouble.hh"
17 #include "CLHEP/Random/Random.h"
18 #include "CLHEP/Random/Randomize.h"
24 using namespace CLHEP;
28 GeneratorMessenger::GeneratorMessenger() {
32 GeneratorMessenger::~GeneratorMessenger() {
35 void GeneratorMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) {
36 std::istringstream is((
const char*) newVals);
44 if (cmd == m_selectCmd) {
48 else if (cmd == m_resetCmd) {
52 else if (cmd == m_skipEventsCmd) {
56 else if (cmd == m_filenameCmd) {
60 else if (cmd == m_enablePrintEventCmd) {
61 G4bool enablePrintEvent = StringUtil::toBool(s);
65 else if (cmd == m_printNumEventsGeneratedCmd) {
69 else if (cmd == m_randomSeedCmd) {
73 if (s != std::string(
"")) {
74 seed = StringUtil::toInt(s);
79 seed = ((unsigned)
time(NULL));
83 HepRandom::setTheSeed(seed);
88 else if (cmd == m_setLorentzTransformationAngleCmd) {
89 EventSourceManager::instance()->setLorentzTransformationAngle(G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newVals));
90 }
else if (cmd == m_setZSmearingParameterCmd) {
91 EventSourceManager::instance()->setZSmearing(G4UIcmdWithADouble::GetNewDoubleValue(newVals));
93 G4Exception(
"",
"", JustWarning,
"Unknown command.");
97 void GeneratorMessenger::defineCommands() {
101 m_generatorDir =
new G4UIdirectory(
"/generator/");
102 m_generatorDir->SetGuidance(
"Event generation commands.");
105 m_selectCmd =
new G4UIcommand(
"/generator/select",
this);
106 m_selectCmd->SetGuidance(
"Set Generator to use: lcio, stdhep, gps or gun.");
107 p =
new G4UIparameter(
"generator",
's',
false);
108 m_selectCmd->SetParameter(p);
111 m_resetCmd =
new G4UIcommand(
"/generator/reset",
this);
112 m_resetCmd->SetGuidance(
"Reset the generator using the current info.");
115 m_skipEventsCmd =
new G4UIcmdWithAnInteger(
"/generator/skipEvents",
this);
116 m_skipEventsCmd->SetGuidance(
"Skip n events of current generator.");
117 m_skipEventsCmd->SetParameterName(
"NumEvents",
false);
120 m_filenameCmd =
new G4UIcommand(
"/generator/filename",
this);
121 m_filenameCmd->SetGuidance(
"Set generator input filename.");
122 p =
new G4UIparameter(
"filename",
's',
false);
123 m_filenameCmd->SetParameter(p);
126 m_enablePrintEventCmd =
new G4UIcommand(
"/generator/printEvent",
this);
127 m_enablePrintEventCmd->SetGuidance(
"Dump information about the current generator event.");
130 m_printNumEventsGeneratedCmd =
new G4UIcommand(
"/generator/printNumEventsGenerated",
this);
131 m_printNumEventsGeneratedCmd->SetGuidance(
"Print out number of events generated with current generator.");
134 m_randomSeedCmd =
new G4UIcommand(
"/random/seed",
this);
135 m_randomSeedCmd->SetGuidance(
"Set random seed; no argument seeds with current time.");
136 p =
new G4UIparameter(
"seedValue",
'i',
true);
137 m_randomSeedCmd->SetParameter(p);
140 m_setLorentzTransformationAngleCmd =
new G4UIcmdWithADoubleAndUnit(
"/generator/setLorentzTransformationAngle",
this);
141 m_setLorentzTransformationAngleCmd->SetGuidance(
"Set the Lorentz transformation angle to boost generated events.");
144 m_setZSmearingParameterCmd =
new G4UIcmdWithADouble(
"/generator/setZSmearingParameter",
this);
145 m_setZSmearingParameterCmd->SetGuidance(
"Set the parameter for smearing vertex Z positions.");
This singleton is responsible for managing physics event sources.
void setFilename(const std::string &fileName)
void enablePrintEvent(G4bool enable)
void resetCurrentEventSource()
void printNumEventsGenerated()
void setSkipEvents(unsigned int n)