File indexing completed on 2026-05-08 08:06:54
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 #ifdef G4LIB_USE_PYTHIA
0030
0031 # include "HepMCG4PythiaInterface.hh"
0032
0033 # include "HepMC/GenEvent.h"
0034 # include "HepMC/PythiaWrapper6_4.h"
0035 # include "HepMCG4PythiaMessenger.hh"
0036
0037
0038
0039 # define pygive pygive_
0040 # define pyrget pyrget_
0041 # define pyrset pyrset_
0042
0043 extern "C"
0044 {
0045 void pygive(const char*, int);
0046 void pyrget(int*, int*);
0047 void pyrset(int*, int*);
0048 }
0049
0050 void call_pygive(G4String s)
0051 {
0052 pygive(s.c_str(), s.length());
0053 }
0054 void call_pyrget(int a, int b)
0055 {
0056 pyrget(&a, &b);
0057 }
0058 void call_pyrset(int a, int b)
0059 {
0060 pyrset(&a, &b);
0061 }
0062
0063
0064 HepMCG4PythiaInterface::HepMCG4PythiaInterface() : verbose(0), mpylist(0)
0065 {
0066 # ifdef NEED_INITPYDATA
0067 initpydata();
0068
0069
0070
0071 # endif
0072
0073 messenger = new HepMCG4PythiaMessenger(this);
0074 }
0075
0076
0077 HepMCG4PythiaInterface::~HepMCG4PythiaInterface()
0078 {
0079 delete messenger;
0080 }
0081
0082
0083 void HepMCG4PythiaInterface::CallPygive(G4String par)
0084 {
0085 call_pygive(par);
0086 }
0087
0088
0089 void HepMCG4PythiaInterface::CallPyinit(G4String frame, G4String beam, G4String target,
0090 G4double win)
0091 {
0092 call_pyinit(frame.c_str(), beam.c_str(), target.c_str(), win);
0093 }
0094
0095
0096 void HepMCG4PythiaInterface::CallPystat(G4int istat)
0097 {
0098 call_pystat(istat);
0099 }
0100
0101
0102 void HepMCG4PythiaInterface::SetRandomSeed(G4int iseed)
0103 {
0104 pydatr.mrpy[1 - 1] = iseed;
0105 }
0106
0107
0108 void HepMCG4PythiaInterface::CallPyrget(G4int lun, G4int move)
0109 {
0110 call_pyrget(lun, move);
0111 }
0112
0113
0114 void HepMCG4PythiaInterface::CallPyrset(G4int lun, G4int move)
0115 {
0116 call_pyrset(lun, move);
0117 }
0118
0119
0120 void HepMCG4PythiaInterface::PrintRandomStatus(std::ostream& ostr) const
0121 {
0122 ostr << "# Pythia random numbers status" << G4endl;
0123 for (G4int j = 0; j < 6; j++) {
0124 ostr << "pydatr.mrpy[" << j << "]= " << pydatr.mrpy[j] << G4endl;
0125 }
0126 for (G4int k = 0; k < 100; k++) {
0127 ostr << "pydatr.rrpy[" << k << "]= " << pydatr.rrpy[k] << G4endl;
0128 }
0129 }
0130
0131
0132 void HepMCG4PythiaInterface::SetUserParameters()
0133 {
0134 G4cout << "set user parameters of PYTHIA common." << G4endl << "nothing to be done in default."
0135 << G4endl;
0136 }
0137
0138
0139 HepMC::GenEvent* HepMCG4PythiaInterface::GenerateHepMCEvent()
0140 {
0141 static G4int nevent = 0;
0142
0143 call_pyevnt();
0144 if (mpylist >= 1 && mpylist <= 3) call_pylist(mpylist);
0145
0146 call_pyhepc(1);
0147
0148 HepMC::GenEvent* evt = hepevtio.read_next_event();
0149 evt->set_event_number(nevent++);
0150 if (verbose > 0) evt->print();
0151
0152 return evt;
0153 }
0154
0155
0156 void HepMCG4PythiaInterface::Print() const
0157 {
0158 G4cout << "PythiaInterface::Print()..." << G4endl;
0159 }
0160
0161 #endif