15#include "CLHEP/Random/RandFlat.h"
16#include "GaudiKernel/MsgStream.h"
24#include "HepMC3/Print.h"
46 size_t len = std::strlen(filename);
50 std::memcpy(
jobfname_.fnjob, filename, len);
51 for (
size_t i = len; i < 1000; ++i) {
58static std::string epos_rndm_stream =
"EPOS4_INIT";
59static CLHEP::HepRandomEngine *p_rndmEngine{};
62extern std::shared_ptr<HepMC3::Writer>
writer;
67 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
68 set_run_info(std::move(
run));
71 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
72 set_run_info(std::move(
run));
74 WriterEPOS([[maybe_unused]] std::shared_ptr<std::ostream> s_stream,
75 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
76 set_run_info(std::move(
run));
81 bool failed()
override {
return false; };
113 epos_rndm_stream =
"EPOS4_INIT";
119namespace fs = std::filesystem;
121 if (filein.size() < 6 || filein.compare(filein.size() - 6, 6,
".optns") != 0) {
123 <<
" does not end with \".optns\"\n");
127 fs::path source = filein;
128 fs::path destination =
130 fs::path(std::string(
"z-") + source.filename().string());
132 std::ifstream src(source);
133 std::ofstream dst(destination);
136 ATH_MSG_ERROR(
" Cannot open source file: " << source <<
"\n");
141 ATH_MSG_ERROR(
" Cannot create destination file: " << destination <<
"\n");
146 while (std::getline(src, line)) {
149 dst <<
"set ihepmc 1" <<
'\n';
151 std::string
file = source.filename().string().size() > 6
152 ? source.filename().string().substr(
153 0, source.filename().string().size() - 6)
156 std::string num =
"0";
157 std::string one =
file;
159 one =
file +
"-" + num;
162 std::string clinput =
"z-" + one +
".clinput";
163 std::ofstream ofile(clinput);
165 std::string CHK = std::getenv(
"CHK")
174 seedj = std::to_string(
m_seeds.at(0));
178 std::string seedi =
m_seeds.size() < 2
184 std::string rootcproot =
"nono";
185 std::string system =
"i";
186 std::string ext1 =
"-";
187 std::string ext3 =
"-";
188 std::string ext4 =
"-";
189 std::string gefac =
"1";
190 auto safeGetenv = [
this](
const char *envName) -> std::string {
191 const char *env = std::getenv(envName);
197 std::string EPO = safeGetenv(
"EPO");
198 std::string SRCEXT = safeGetenv(
"SRCEXT");
199 std::string HTO = safeGetenv(
"HTO");
200 std::string SRC = safeGetenv(
"SRC");
201 std::string CONF = safeGetenv(
"CONF");
202 std::string OPT = safeGetenv(
"OPT");
203 std::string OPX =
"";
204 if (std::string(OPT) ==
"./") {
205 OPX = std::filesystem::current_path().string() +
"/";
207 OPX = std::move(OPT);
211 <<
"EPO: " << EPO <<
"\n"
212 <<
"SRCEXT: " << SRCEXT <<
"\n"
213 <<
" HTO: " << HTO <<
"\n"
214 <<
" SRC: " << SRC <<
"\n"
215 <<
" OPX: " << OPX <<
"\n"
216 <<
" CHK: " << CHK <<
"\n"
220 ofile <<
"!fname mtr " << CHK <<
"z-" << one <<
".mtr\n";
221 ofile <<
"set seedj " << seedj <<
" set seedi " << seedi <<
"\n";
222 ofile <<
"echo off\n";
223 ofile <<
"rootcproot " << rootcproot <<
"\n";
224 ofile <<
"system " << system <<
"\n";
225 ofile <<
"ext1 " << ext1 <<
"\n";
226 ofile <<
"ext3 " << ext3 <<
"\n";
227 ofile <<
"ext4 " << ext4 <<
"\n";
228 ofile <<
"set gefac " << gefac <<
"\n";
229 ofile <<
"!!!beginoptns spherio !No longer used.\n";
230 ofile <<
"!!!... !See version < 3118 \n";
231 ofile <<
"!!!endoptns spherio !if needed again \n";
232 ofile <<
"fname pathep " << EPO <<
"\n";
233 ofile <<
"!-------HQ--------\n";
234 ofile <<
"fname user1 " << SRCEXT <<
"/HQt/\n";
235 ofile <<
"fname user2 " << HTO <<
"z-" << one <<
".hq\n";
236 ofile <<
"fname user3 " << SRCEXT <<
"/URt/\n";
237 ofile <<
"!-------HQ END--------\n";
238 ofile <<
"fname pathpdf " << SRC <<
"/TPt/\n";
239 ofile <<
"fname histo " << HTO <<
"z-" << one <<
".histo\n";
240 ofile <<
"fname check " << CHK <<
"z-" << one <<
".check\n";
241 ofile <<
"fname copy " << CHK <<
"z-" << one <<
".copy\n";
242 ofile <<
"fname log " << CHK <<
"z-" << one <<
".log\n";
243 ofile <<
"fname data " << CHK <<
"z-" << one <<
".data\n";
244 ofile <<
"fname initl " << SRC <<
"/KWt/aa.i\n";
245 ofile <<
"fname inidi " << SRC <<
"/TPt/di.i\n";
246 ofile <<
"fname inidr " << SRC <<
"/KWt/dr.i\n";
247 ofile <<
"fname iniev " << SRC <<
"/KWt/ev.i\n";
248 ofile <<
"fname inirj " << SRC <<
"/KWt/rj.i\n";
249 ofile <<
"fname inics " << SRC <<
"/TPt/cs.i\n";
250 ofile <<
"fname inigrv " << SRC <<
"/grv.i\n";
251 ofile <<
"fname partab " << SRCEXT <<
"/YK/ptl6.data\n";
252 ofile <<
"fname dectab " << SRCEXT <<
"/YK/dky6.data\n";
253 ofile <<
"fname hpf " << SRCEXT <<
"/UR/tables.dat \n";
254 ofile <<
"!fqgsjet dat " << EPO << SRC
255 <<
"qgsjet/qgsjet.dat !No longer used.\n";
256 ofile <<
"!fqgsjet ncs " << EPO << SRC
257 <<
"qgsjet/qgsjet.ncs !No longer used.\n";
258 ofile <<
"!fqgsjetII dat " << EPO << SRC
259 <<
"qgsjetII/qgsdat-II-03 !No longer used.\n";
260 ofile <<
"!fqgsjetII ncs " << EPO << SRC
261 <<
"qgsjetII/sectnu-II-03 !No longer used.\n";
262 ofile <<
"nodecay 1220\n";
263 ofile <<
"nodecay -1220\n";
264 ofile <<
"nodecay 120\n";
265 ofile <<
"nodecay -120\n";
266 ofile <<
"nodecay 130\n";
267 ofile <<
"nodecay -130\n";
268 ofile <<
"nodecay -20\n";
269 ofile <<
"nodecay 14\n";
270 ofile <<
"nodecay -14\n";
271 ofile <<
"nodecay 16\n";
272 ofile <<
"nodecay -16\n";
273 ofile <<
"echo on\n";
274 ofile <<
"input " << CONF <<
"/parbf.i\n";
275 ofile <<
"input " << OPX <<
"z-" << one <<
".optns\n";
276 ofile <<
"input " << SRC <<
"/KWn/paraf.i\n";
277 ofile <<
"input " << CONF <<
"/partx.i\n";
278 ofile <<
"runprogram\n";
279 ofile <<
"stopprogram\n";
289 epos_rndm_stream =
"EPOS4";
292 writer = std::make_shared<HepMC3::WriterEPOS>(
"foo");
303 for (
int k = 1; k <= currentnumberOfEnergyValues; k++) {
310 return StatusCode::SUCCESS;
318 const EventContext &ctx = Gaudi::Hive::currentContext();
320 ctx.eventID().event_number(),
m_dsid,
322 p_rndmEngine->setSeeds(seeds, 0);
324 const long *s = p_rndmEngine->getSeeds();
331 return StatusCode::SUCCESS;
345 return StatusCode::SUCCESS;
351 std::dynamic_pointer_cast<HepMC3::WriterEPOS>(
writer)->current_event();
354 e.set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
356 <<
" | particles: " << e.particles().size()
357 <<
" | vertices: " << e.vertices().size());
359 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.
HepMC3::GenEvent GenEvent
int run(int argc, char *argv[])