15#include "CLHEP/Random/RandFlat.h"
16#include "GaudiKernel/MsgStream.h"
22#include "HepMC3/GenEvent.h"
23#include "HepMC3/Writer.h"
24#include "HepMC3/Print.h"
25#include "HepMC3/GenEvent.h"
45 size_t len = std::strlen(filename);
49 std::memcpy(
jobfname_.fnjob, filename, len);
50 for (
size_t i = len; i < 1000; ++i) {
57static std::string epos_rndm_stream =
"EPOS4_INIT";
58static CLHEP::HepRandomEngine *p_rndmEngine{};
61extern std::shared_ptr<HepMC3::Writer>
writer;
66 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
67 set_run_info(std::move(
run));
70 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
71 set_run_info(std::move(
run));
73 WriterEPOS([[maybe_unused]] std::shared_ptr<std::ostream> s_stream,
74 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
75 set_run_info(std::move(
run));
80 bool failed()
override {
return false; };
112 epos_rndm_stream =
"EPOS4_INIT";
119namespace fs = std::filesystem;
122 if (filein.size() < 6 ||
123 filein.compare(filein.size() - 6, 6,
".optns") != 0) {
125 <<
" does not end with \".optns\"\n");
129 fs::path source = filein;
130 fs::path destination =
132 fs::path(std::string(
"z-") + source.filename().string());
134 std::ifstream src(source);
135 std::ofstream dst(destination);
138 ATH_MSG_ERROR(
" Cannot open source file: " << source <<
"\n");
143 ATH_MSG_ERROR(
" Cannot create destination file: " << destination <<
"\n");
148 while (std::getline(src, line)) {
151 dst <<
"set ihepmc 1" <<
'\n';
153 std::string
file = source.filename().string().size() > 6
154 ? source.filename().string().substr(
155 0, source.filename().string().size() - 6)
158 std::string num =
"0";
159 std::string one =
file;
161 one =
file +
"-" + num;
164 std::string clinput =
"z-" + one +
".clinput";
165 std::ofstream ofile(clinput);
167 std::string CHK = std::getenv(
"CHK")
172 std::string seedi =
m_seeds.size() < 1
177 std::string seedj =
m_seeds.size() < 2
181 std::string rootcproot =
"nono";
182 std::string system =
"i";
183 std::string ext1 =
"-";
184 std::string ext3 =
"-";
185 std::string ext4 =
"-";
186 std::string gefac =
"1";
187 auto safeGetenv = [
this](
const char *envName) -> std::string {
188 const char *env = std::getenv(envName);
194 std::string EPO = safeGetenv(
"EPO");
195 std::string SRCEXT = safeGetenv(
"SRCEXT");
196 std::string HTO = safeGetenv(
"HTO");
197 std::string SRC = safeGetenv(
"SRC");
198 std::string CONF = safeGetenv(
"CONF");
199 std::string OPT = safeGetenv(
"OPT");
200 std::string OPX =
"";
201 if (std::string(OPT) ==
"./") {
202 OPX = std::filesystem::current_path().string() +
"/";
204 OPX = std::move(OPT);
207 ofile <<
"!fname mtr " << CHK <<
"z-" << one <<
".mtr\n";
208 ofile <<
"set seedj " << seedj <<
" set seedi " << seedi <<
"\n";
209 ofile <<
"echo off\n";
210 ofile <<
"rootcproot " << rootcproot <<
"\n";
211 ofile <<
"system " << system <<
"\n";
212 ofile <<
"ext1 " << ext1 <<
"\n";
213 ofile <<
"ext3 " << ext3 <<
"\n";
214 ofile <<
"ext4 " << ext4 <<
"\n";
215 ofile <<
"set gefac " << gefac <<
"\n";
216 ofile <<
"!!!beginoptns spherio !No longer used.\n";
217 ofile <<
"!!!... !See version < 3118 \n";
218 ofile <<
"!!!endoptns spherio !if needed again \n";
219 ofile <<
"fname pathep " << EPO <<
"\n";
220 ofile <<
"!-------HQ--------\n";
221 ofile <<
"fname user1 " << SRCEXT <<
"/HQt/\n";
222 ofile <<
"fname user2 " << HTO <<
"z-" << one <<
".hq\n";
223 ofile <<
"fname user3 " << SRCEXT <<
"/URt/\n";
224 ofile <<
"!-------HQ END--------\n";
225 ofile <<
"fname pathpdf " << SRC <<
"/TPt/\n";
226 ofile <<
"fname histo " << HTO <<
"z-" << one <<
".histo\n";
227 ofile <<
"fname check " << CHK <<
"z-" << one <<
".check\n";
228 ofile <<
"fname copy " << CHK <<
"z-" << one <<
".copy\n";
229 ofile <<
"fname log " << CHK <<
"z-" << one <<
".log\n";
230 ofile <<
"fname data " << CHK <<
"z-" << one <<
".data\n";
231 ofile <<
"fname initl " << SRC <<
"/KWt/aa.i\n";
232 ofile <<
"fname inidi " << SRC <<
"/TPt/di.i\n";
233 ofile <<
"fname inidr " << SRC <<
"/KWt/dr.i\n";
234 ofile <<
"fname iniev " << SRC <<
"/KWt/ev.i\n";
235 ofile <<
"fname inirj " << SRC <<
"/KWt/rj.i\n";
236 ofile <<
"fname inics " << SRC <<
"/TPt/cs.i\n";
237 ofile <<
"fname inigrv " << SRC <<
"/grv.i\n";
238 ofile <<
"fname partab " << SRCEXT <<
"/YK/ptl6.data\n";
239 ofile <<
"fname dectab " << SRCEXT <<
"/YK/dky6.data\n";
240 ofile <<
"fname hpf " << SRCEXT <<
"/UR/tables.dat \n";
241 ofile <<
"!fqgsjet dat " << EPO << SRC
242 <<
"qgsjet/qgsjet.dat !No longer used.\n";
243 ofile <<
"!fqgsjet ncs " << EPO << SRC
244 <<
"qgsjet/qgsjet.ncs !No longer used.\n";
245 ofile <<
"!fqgsjetII dat " << EPO << SRC
246 <<
"qgsjetII/qgsdat-II-03 !No longer used.\n";
247 ofile <<
"!fqgsjetII ncs " << EPO << SRC
248 <<
"qgsjetII/sectnu-II-03 !No longer used.\n";
249 ofile <<
"nodecay 1220\n";
250 ofile <<
"nodecay -1220\n";
251 ofile <<
"nodecay 120\n";
252 ofile <<
"nodecay -120\n";
253 ofile <<
"nodecay 130\n";
254 ofile <<
"nodecay -130\n";
255 ofile <<
"nodecay -20\n";
256 ofile <<
"nodecay 14\n";
257 ofile <<
"nodecay -14\n";
258 ofile <<
"nodecay 16\n";
259 ofile <<
"nodecay -16\n";
260 ofile <<
"echo on\n";
261 ofile <<
"input " << CONF <<
"/parbf.i\n";
262 ofile <<
"input " << OPX <<
"z-" << one <<
".optns\n";
263 ofile <<
"input " << SRC <<
"/KWn/paraf.i\n";
264 ofile <<
"input " << CONF <<
"/partx.i\n";
265 ofile <<
"runprogram\n";
266 ofile <<
"stopprogram\n";
276 epos_rndm_stream =
"EPOS4";
279 writer = std::make_shared<HepMC3::WriterEPOS>(
"foo");
290 for (
int k = 1; k <= currentnumberOfEnergyValues; k++) {
297 return StatusCode::SUCCESS;
304 const EventContext &ctx = Gaudi::Hive::currentContext();
306 ctx.eventID().event_number(),
m_dsid,
308 p_rndmEngine->setSeeds(seeds, 0);
310 const long *s = p_rndmEngine->getSeeds();
317 return StatusCode::SUCCESS;
330 return StatusCode::SUCCESS;
336 std::dynamic_pointer_cast<HepMC3::WriterEPOS>(
writer)->current_event();
339 e.set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
340 HepMC3::Print::content(e);
343 return StatusCode::SUCCESS;
#define ATH_MSG_WARNING(x)
int numberOfEnergyValues()
void finalizeSimulation()
std::shared_ptr< HepMC3::Writer > writer
void initializeElectronProtonPart()
int setEnergyIndex(int &)
void set_job_common(const char *filename)
void listParticles(int &)
void initializeEventCounters()
struct jobfnametype jobfname_
void generateEposEvent(int &)
void defineStorageSettings()
void initializeHeavyQuarkPart()
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode genFinalize() override
For finalising the generator, if required.
virtual StatusCode genInitialize() override
For initializing the generator, if required.
virtual StatusCode callGenerator() override
For calling the generator on each iteration of the event loop.
std::string create_file(const std::string &filein)
Epos4(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< long int > m_seeds
virtual StatusCode fillEvt(HepMC::GenEvent *evt) override
For filling the HepMC event object.
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize(const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const
IntegerProperty m_randomSeed
Seed for random number engine.
WriterEPOS(std::shared_ptr< std::ostream > s_stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
const GenEvent & current_event() const
void write_event(const GenEvent &evt) override
WriterEPOS(std::ostream &stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
WriterEPOS(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
void calculateSeedsMC21(long *seeds, const std::string &algName, uint64_t ev, uint64_t run, uint64_t offset=0)
Set the random seed using a string (e.g.
int run(int argc, char *argv[])