ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepMCG4PythiaMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HepMCG4PythiaMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 
31 #ifdef G4LIB_USE_PYTHIA
32 
33 #include <sstream>
34 #include <fstream>
35 #include "G4UIdirectory.hh"
37 #include "G4UIcmdWithAString.hh"
38 #include "G4UIcmdWithAnInteger.hh"
39 #include "HepMCG4PythiaMessenger.hh"
40 #include "HepMCG4PythiaInterface.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44  : gen(agen)
45 {
46  dir= new G4UIdirectory("/generator/pythia/");
47  dir-> SetGuidance("Commands for Pythia event generation");
48 
49  verbose= new G4UIcmdWithAnInteger("/generator/pythia/verbose",this);
50  verbose-> SetGuidance("set verbose level");
51  verbose-> SetParameterName("verboseLevel", false, false);
52  verbose-> SetRange("verboseLevel>=0 && verboseLevel<=2");
53 
54  mpylist= new G4UIcmdWithAnInteger("/generator/pythia/pylist",this);
55  mpylist-> SetGuidance("set argument of pylist (not called if mlist=0)");
56  mpylist-> SetParameterName("mlist", false, false);
57  mpylist-> SetRange("mlist>=0 && mlist<=3");
58 
59  print= new G4UIcmdWithoutParameter("/generator/pythia/print", this);
60  print-> SetGuidance("print user information.");
61 
62  cpyinit= new G4UIcommand("/generator/pythia/pyinit", this);
63  cpyinit-> SetGuidance("call PYINIT");
64  G4UIparameter* frame=
65  new G4UIparameter("frame of the experiment", 's', false);
66  cpyinit-> SetParameter(frame);
67  G4UIparameter* beam= new G4UIparameter("beam particle", 's', false);
68  cpyinit-> SetParameter(beam);
69  G4UIparameter* target= new G4UIparameter("target particle", 's', false);
70  cpyinit-> SetParameter(target);
71  G4UIparameter* win= new G4UIparameter("energy of system (GeV)", 'd', false);
72  cpyinit-> SetParameter(win);
73 
74  cpystat= new G4UIcmdWithAnInteger("/generator/pythia/pystat", this);
75  cpystat-> SetGuidance("call PYSTAT");
76  cpystat-> SetParameterName("mstat", false, false);
77  cpystat-> SetRange("mstat>=1 && mstat<=5");
78 
79  cpygive= new G4UIcommand("/generator/pythia/pygive",this);
80  cpygive-> SetGuidance("call PYGIVE");
81  G4UIparameter* parameter= new G4UIparameter ("Parameter", 's', false);
82  cpygive-> SetParameter(parameter);
83 
84  setUserParameters=
85  new G4UIcmdWithoutParameter("/generator/pythia/setUserParameters",this);
86  setUserParameters->
87  SetGuidance("Set user parameters in the Pythia common blocks");
88 
89  setSeed= new G4UIcmdWithAnInteger("/generator/pythia/setSeed", this);
90  setSeed-> SetGuidance("set initial seed.");
91 
92  cpyrget= new G4UIcommand("/generator/pythia/pyrget", this);
93  cpyrget-> SetGuidance("call PYRGET");
94  G4UIparameter* lun, *move;
95  lun= new G4UIparameter("logical file number", 'i', false);
96  cpyrget-> SetParameter(lun);
97  move= new G4UIparameter("choice of adding a new record", 'i', true);
98  move-> SetDefaultValue(-1);
99  cpyrget-> SetParameter(move);
100 
101  cpyrset= new G4UIcommand("/generator/pythia/pyrset", this);
102  cpyrset-> SetGuidance("call PYRSET");
103  lun= new G4UIparameter("logical file number", 'i', false);
104  cpyrset-> SetParameter(lun);
105  move= new G4UIparameter("choice of adding a new record", 'i', true);
106  move-> SetDefaultValue(0);
107  cpyrset-> SetParameter(move);
108 
109  printRandomStatus=
110  new G4UIcmdWithAString("/generator/pythia/printRandomStatus", this);
111  printRandomStatus-> SetGuidance("print random number status.");
112  printRandomStatus-> SetParameterName("filename", true, false);
113  printRandomStatus-> SetDefaultValue("std::cout");
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 {
119  delete verbose;
120  delete mpylist;
121  delete print;
122  delete cpyinit;
123  delete cpystat;
124  delete cpygive;
125  delete setUserParameters;
126  delete setSeed;
127  delete cpyrget;
128  delete cpyrset;
129  delete printRandomStatus;
130 
131  delete dir;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136  G4String newValues)
137 {
138  if(command == verbose) { // /verbose ...
139  G4int level= verbose-> GetNewIntValue(newValues);
140  gen-> SetVerboseLevel(level);
141 
142  } else if (command == mpylist) { // /mpylist ...
143  G4int mlist= mpylist-> GetNewIntValue(newValues);
144  gen-> SetPylist(mlist);
145 
146  } else if (command == print) { // /print ...
147  gen-> Print();
148 
149  } else if (command == cpyinit) { // /pyinit ...
150  const char* strvaluelist= newValues.c_str();
151  std::istringstream is(strvaluelist);
152  G4String sframe, sbeam, starget; G4double dwin;
153  is >> sframe >> sbeam >> starget >> dwin;
154  gen-> CallPyinit(sframe, sbeam, starget, dwin);
155 
156  } else if (command == cpystat) { // /pystat ...
157  G4int imod= cpystat-> GetNewIntValue(newValues);
158  gen-> CallPystat(imod);
159 
160  } else if (command == cpygive) { // /pygive ...
161  G4String s= newValues;
162  gen-> CallPygive(s);
163 
164  } else if (command == setUserParameters) { // /setUserParameters ...
165  gen-> SetUserParameters();
166 
167  } else if (command == setSeed) { // /setSeed ...
168  G4int iseed= setSeed-> GetNewIntValue(newValues);
169  gen-> SetRandomSeed(iseed);
170 
171  } else if (command == cpyrget) { // /pyrget ...
172  const char* strvaluelist= newValues.c_str();
173  std::istringstream is(strvaluelist);
174  G4int lun, move;
175  is >> lun >> move;
176  gen-> CallPyrget(lun, move);
177 
178  } else if (command == cpyrset) { // /pyrset ...
179  const char* strvaluelist= newValues.c_str();
180  std::istringstream is(strvaluelist);
181  G4int lun, move;
182  is >> lun >> move;
183  gen-> CallPyrset(lun, move);
184 
185  } else if (command == printRandomStatus) { // /printRandomStatus ...
186  G4String s= newValues;
187  if (newValues == "std::cout") {
188  gen-> PrintRandomStatus();
189  } else {
190  // to a file (overwrite mode)
191  std::ofstream ofs;
192  ofs.open(s.c_str(), std::ios::out);
193  //ofs.open(randomStatusFileName.c_str(), std::ios::out|std::ios::app);
194  ofs.setf(std::ios::fixed | std::ios::showpoint);
195  gen-> PrintRandomStatus(ofs);
196  ofs.close();
197  }
198  }
199 }
200 
201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203 {
204  G4String cv;
205  if (command == verbose) {
206  cv= verbose-> ConvertToString(gen->GetVerboseLevel());
207  } else if (command == mpylist) {
208  cv= verbose-> ConvertToString(gen->GetPylist());
209  }
210  return cv;
211 }
212 
213 #endif