File indexing completed on 2025-04-10 08:05:41
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 #ifdef G4LIB_USE_PYTHIA
0032
0033 # include "HepMCG4PythiaMessenger.hh"
0034
0035 # include "HepMCG4PythiaInterface.hh"
0036
0037 # include "G4UIcmdWithAString.hh"
0038 # include "G4UIcmdWithAnInteger.hh"
0039 # include "G4UIcmdWithoutParameter.hh"
0040 # include "G4UIdirectory.hh"
0041
0042 # include <fstream>
0043 # include <sstream>
0044
0045
0046 HepMCG4PythiaMessenger::HepMCG4PythiaMessenger(HepMCG4PythiaInterface* agen) : gen(agen)
0047 {
0048 dir = new G4UIdirectory("/generator/pythia/");
0049 dir->SetGuidance("Commands for Pythia event generation");
0050
0051 verbose = new G4UIcmdWithAnInteger("/generator/pythia/verbose", this);
0052 verbose->SetGuidance("set verbose level");
0053 verbose->SetParameterName("verboseLevel", false, false);
0054 verbose->SetRange("verboseLevel>=0 && verboseLevel<=2");
0055
0056 mpylist = new G4UIcmdWithAnInteger("/generator/pythia/pylist", this);
0057 mpylist->SetGuidance("set argument of pylist (not called if mlist=0)");
0058 mpylist->SetParameterName("mlist", false, false);
0059 mpylist->SetRange("mlist>=0 && mlist<=3");
0060
0061 print = new G4UIcmdWithoutParameter("/generator/pythia/print", this);
0062 print->SetGuidance("print user information.");
0063
0064 cpyinit = new G4UIcommand("/generator/pythia/pyinit", this);
0065 cpyinit->SetGuidance("call PYINIT");
0066 G4UIparameter* frame = new G4UIparameter("frame of the experiment", 's', false);
0067 cpyinit->SetParameter(frame);
0068 G4UIparameter* beam = new G4UIparameter("beam particle", 's', false);
0069 cpyinit->SetParameter(beam);
0070 G4UIparameter* target = new G4UIparameter("target particle", 's', false);
0071 cpyinit->SetParameter(target);
0072 G4UIparameter* win = new G4UIparameter("energy of system (GeV)", 'd', false);
0073 cpyinit->SetParameter(win);
0074
0075 cpystat = new G4UIcmdWithAnInteger("/generator/pythia/pystat", this);
0076 cpystat->SetGuidance("call PYSTAT");
0077 cpystat->SetParameterName("mstat", false, false);
0078 cpystat->SetRange("mstat>=1 && mstat<=5");
0079
0080 cpygive = new G4UIcommand("/generator/pythia/pygive", this);
0081 cpygive->SetGuidance("call PYGIVE");
0082 G4UIparameter* parameter = new G4UIparameter("Parameter", 's', false);
0083 cpygive->SetParameter(parameter);
0084
0085 setUserParameters = new G4UIcmdWithoutParameter("/generator/pythia/setUserParameters", this);
0086 setUserParameters->SetGuidance("Set user parameters in the Pythia common blocks");
0087
0088 setSeed = new G4UIcmdWithAnInteger("/generator/pythia/setSeed", this);
0089 setSeed->SetGuidance("set initial seed.");
0090
0091 cpyrget = new G4UIcommand("/generator/pythia/pyrget", this);
0092 cpyrget->SetGuidance("call PYRGET");
0093 G4UIparameter *lun, *move;
0094 lun = new G4UIparameter("logical file number", 'i', false);
0095 cpyrget->SetParameter(lun);
0096 move = new G4UIparameter("choice of adding a new record", 'i', true);
0097 move->SetDefaultValue(-1);
0098 cpyrget->SetParameter(move);
0099
0100 cpyrset = new G4UIcommand("/generator/pythia/pyrset", this);
0101 cpyrset->SetGuidance("call PYRSET");
0102 lun = new G4UIparameter("logical file number", 'i', false);
0103 cpyrset->SetParameter(lun);
0104 move = new G4UIparameter("choice of adding a new record", 'i', true);
0105 move->SetDefaultValue(0);
0106 cpyrset->SetParameter(move);
0107
0108 printRandomStatus = new G4UIcmdWithAString("/generator/pythia/printRandomStatus", this);
0109 printRandomStatus->SetGuidance("print random number status.");
0110 printRandomStatus->SetParameterName("filename", true, false);
0111 printRandomStatus->SetDefaultValue("std::cout");
0112 }
0113
0114
0115 HepMCG4PythiaMessenger::~HepMCG4PythiaMessenger()
0116 {
0117 delete verbose;
0118 delete mpylist;
0119 delete print;
0120 delete cpyinit;
0121 delete cpystat;
0122 delete cpygive;
0123 delete setUserParameters;
0124 delete setSeed;
0125 delete cpyrget;
0126 delete cpyrset;
0127 delete printRandomStatus;
0128
0129 delete dir;
0130 }
0131
0132
0133 void HepMCG4PythiaMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
0134 {
0135 if (command == verbose) {
0136 G4int level = verbose->GetNewIntValue(newValues);
0137 gen->SetVerboseLevel(level);
0138 }
0139 else if (command == mpylist) {
0140 G4int mlist = mpylist->GetNewIntValue(newValues);
0141 gen->SetPylist(mlist);
0142 }
0143 else if (command == print) {
0144 gen->Print();
0145 }
0146 else if (command == cpyinit) {
0147 const char* strvaluelist = newValues.c_str();
0148 std::istringstream is(strvaluelist);
0149 G4String sframe, sbeam, starget;
0150 G4double dwin;
0151 is >> sframe >> sbeam >> starget >> dwin;
0152 gen->CallPyinit(sframe, sbeam, starget, dwin);
0153 }
0154 else if (command == cpystat) {
0155 G4int imod = cpystat->GetNewIntValue(newValues);
0156 gen->CallPystat(imod);
0157 }
0158 else if (command == cpygive) {
0159 G4String s = newValues;
0160 gen->CallPygive(s);
0161 }
0162 else if (command == setUserParameters) {
0163 gen->SetUserParameters();
0164 }
0165 else if (command == setSeed) {
0166 G4int iseed = setSeed->GetNewIntValue(newValues);
0167 gen->SetRandomSeed(iseed);
0168 }
0169 else if (command == cpyrget) {
0170 const char* strvaluelist = newValues.c_str();
0171 std::istringstream is(strvaluelist);
0172 G4int lun, move;
0173 is >> lun >> move;
0174 gen->CallPyrget(lun, move);
0175 }
0176 else if (command == cpyrset) {
0177 const char* strvaluelist = newValues.c_str();
0178 std::istringstream is(strvaluelist);
0179 G4int lun, move;
0180 is >> lun >> move;
0181 gen->CallPyrset(lun, move);
0182 }
0183 else if (command == printRandomStatus) {
0184 G4String s = newValues;
0185 if (newValues == "std::cout") {
0186 gen->PrintRandomStatus();
0187 }
0188 else {
0189
0190 std::ofstream ofs;
0191 ofs.open(s.c_str(), std::ios::out);
0192
0193 ofs.setf(std::ios::fixed | std::ios::showpoint);
0194 gen->PrintRandomStatus(ofs);
0195 ofs.close();
0196 }
0197 }
0198 }
0199
0200
0201 G4String HepMCG4PythiaMessenger::GetCurrentValue(G4UIcommand* command)
0202 {
0203 G4String cv;
0204 if (command == verbose) {
0205 cv = verbose->ConvertToString(gen->GetVerboseLevel());
0206 }
0207 else if (command == mpylist) {
0208 cv = verbose->ConvertToString(gen->GetPylist());
0209 }
0210 return cv;
0211 }
0212
0213 #endif