36 #ifdef G4LIB_USE_PYTHIA
38 #include "HepMCG4PythiaMessenger.hh"
39 #include "HepMCG4PythiaInterface.hh"
44 #include "G4UIdirectory.hh"
45 #include "G4UIcmdWithoutParameter.hh"
46 #include "G4UIcmdWithAString.hh"
47 #include "G4UIcmdWithAnInteger.hh"
50 HepMCG4PythiaMessenger::HepMCG4PythiaMessenger(HepMCG4PythiaInterface* agen)
54 dir =
new G4UIdirectory(
"/generator/pythia/");
55 dir-> SetGuidance(
"Commands for Pythia event generation");
57 verbose =
new G4UIcmdWithAnInteger(
"/generator/pythia/verbose",
this);
58 verbose-> SetGuidance(
"set verbose level");
59 verbose-> SetParameterName(
"verboseLevel",
false,
false);
60 verbose-> SetRange(
"verboseLevel>=0 && verboseLevel<=2");
62 mpylist =
new G4UIcmdWithAnInteger(
"/generator/pythia/pylist",
this);
63 mpylist-> SetGuidance(
"set argument of pylist (not called if mlist=0)");
64 mpylist-> SetParameterName(
"mlist",
false,
false);
65 mpylist-> SetRange(
"mlist>=0 && mlist<=3");
67 print =
new G4UIcmdWithoutParameter(
"/generator/pythia/print",
this);
68 print-> SetGuidance(
"print user information.");
70 cpyinit =
new G4UIcommand(
"/generator/pythia/pyinit",
this);
71 cpyinit-> SetGuidance(
"call PYINIT");
72 G4UIparameter* frame =
73 new G4UIparameter(
"frame of the experiment",
's',
false);
74 cpyinit-> SetParameter(frame);
75 G4UIparameter* beam =
new G4UIparameter(
"beam particle",
's',
false);
76 cpyinit-> SetParameter(beam);
77 G4UIparameter* target =
new G4UIparameter(
"target particle",
's',
false);
78 cpyinit-> SetParameter(target);
79 G4UIparameter* win =
new G4UIparameter(
"energy of system (GeV)",
'd',
false);
80 cpyinit-> SetParameter(win);
82 cpystat =
new G4UIcmdWithAnInteger(
"/generator/pythia/pystat",
this);
83 cpystat-> SetGuidance(
"call PYSTAT");
84 cpystat-> SetParameterName(
"mstat",
false,
false);
85 cpystat-> SetRange(
"mstat>=1 && mstat<=5");
87 cpygive =
new G4UIcommand(
"/generator/pythia/pygive",
this);
88 cpygive-> SetGuidance(
"call PYGIVE");
89 G4UIparameter* parameter =
new G4UIparameter (
"Parameter",
's',
false);
90 cpygive-> SetParameter(parameter);
93 new G4UIcmdWithoutParameter(
"/generator/pythia/setUserParameters",
this);
95 SetGuidance(
"Set user parameters in the Pythia common blocks");
97 setSeed =
new G4UIcmdWithAnInteger(
"/generator/pythia/setSeed",
this);
98 setSeed-> SetGuidance(
"set initial seed.");
100 cpyrget =
new G4UIcommand(
"/generator/pythia/pyrget",
this);
101 cpyrget-> SetGuidance(
"call PYRGET");
102 G4UIparameter* lun, *move;
103 lun =
new G4UIparameter(
"logical file number",
'i',
false);
104 cpyrget-> SetParameter(lun);
105 move =
new G4UIparameter(
"choice of adding a new record",
'i',
true);
106 move-> SetDefaultValue(-1);
107 cpyrget-> SetParameter(move);
109 cpyrset =
new G4UIcommand(
"/generator/pythia/pyrset",
this);
110 cpyrset-> SetGuidance(
"call PYRSET");
111 lun =
new G4UIparameter(
"logical file number",
'i',
false);
112 cpyrset-> SetParameter(lun);
113 move =
new G4UIparameter(
"choice of adding a new record",
'i',
true);
114 move-> SetDefaultValue(0);
115 cpyrset-> SetParameter(move);
118 new G4UIcmdWithAString(
"/generator/pythia/printRandomStatus",
this);
119 printRandomStatus-> SetGuidance(
"print random number status.");
120 printRandomStatus-> SetParameterName(
"filename",
true,
false);
121 printRandomStatus-> SetDefaultValue(
"std::cout");
125 HepMCG4PythiaMessenger::~HepMCG4PythiaMessenger()
134 delete setUserParameters;
138 delete printRandomStatus;
144 void HepMCG4PythiaMessenger::SetNewValue(G4UIcommand* command,
148 if(command == verbose) {
149 G4int level = verbose-> GetNewIntValue(newValues);
150 gen-> SetVerboseLevel(level);
152 }
else if (command == mpylist) {
153 G4int mlist = mpylist-> GetNewIntValue(newValues);
154 gen-> SetPylist(mlist);
156 }
else if (command == print) {
159 }
else if (command == cpyinit) {
160 const char* strvaluelist = newValues.c_str();
161 std::istringstream is(strvaluelist);
162 G4String sframe, sbeam, starget;
164 is >> sframe >> sbeam >> starget >> dwin;
165 gen-> CallPyinit(sframe, sbeam, starget, dwin);
167 }
else if (command == cpystat) {
168 G4int imod = cpystat-> GetNewIntValue(newValues);
169 gen-> CallPystat(imod);
171 }
else if (command == cpygive) {
172 G4String s = newValues;
175 }
else if (command == setUserParameters) {
176 gen-> SetUserParameters();
178 }
else if (command == setSeed) {
179 G4int iseed = setSeed-> GetNewIntValue(newValues);
180 gen-> SetRandomSeed(iseed);
182 }
else if (command == cpyrget) {
183 const char* strvaluelist = newValues.c_str();
184 std::istringstream is(strvaluelist);
187 gen-> CallPyrget(lun, move);
189 }
else if (command == cpyrset) {
190 const char* strvaluelist = newValues.c_str();
191 std::istringstream is(strvaluelist);
194 gen-> CallPyrset(lun, move);
196 }
else if (command == printRandomStatus) {
197 G4String s = newValues;
198 if (newValues ==
"std::cout") {
199 gen-> PrintRandomStatus();
203 ofs.open(s.c_str(), std::ios::out);
205 ofs.setf(std::ios::fixed | std::ios::showpoint);
206 gen-> PrintRandomStatus(ofs);
213 G4String HepMCG4PythiaMessenger::GetCurrentValue(G4UIcommand* command)
217 if (command == verbose) {
218 cv = verbose-> ConvertToString(gen->GetVerboseLevel());
219 }
else if (command == mpylist) {
220 cv = verbose-> ConvertToString(gen->GetPylist());