15#include "CLHEP/Random/RandFlat.h"
16#include "GaudiKernel/MsgStream.h"
23#include "HepMC3/GenEvent.h"
24#include "HepMC3/Print.h"
25#include "HepMC3/Writer.h"
47 size_t len = std::strlen(filename);
51 std::memcpy(
jobfname_.fnjob, filename, len);
52 for (
size_t i = len; i < 1000; ++i) {
59static std::string epos_rndm_stream =
"EPOS4_INIT";
60static CLHEP::HepRandomEngine *p_rndmEngine{};
63extern std::shared_ptr<HepMC3::Writer>
writer;
68 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
69 set_run_info(std::move(
run));
72 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
73 set_run_info(std::move(
run));
75 WriterEPOS([[maybe_unused]] std::shared_ptr<std::ostream> s_stream,
76 std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
77 set_run_info(std::move(
run));
82 bool failed()
override {
return false; };
114 epos_rndm_stream =
"EPOS4_INIT";
120namespace fs = std::filesystem;
122 if (filein.size() < 6 || filein.compare(filein.size() - 6, 6,
".optns") != 0) {
124 <<
" does not end with \".optns\"\n");
128 fs::path source = filein;
129 fs::path destination =
131 fs::path(std::string(
"z-") + source.filename().string());
133 std::ifstream src(source);
134 std::ofstream dst(destination);
137 ATH_MSG_ERROR(
" Cannot open source file: " << source <<
"\n");
142 ATH_MSG_ERROR(
" Cannot create destination file: " << destination <<
"\n");
147 while (std::getline(src, line)) {
150 dst <<
"set ihepmc 1" <<
'\n';
152 std::string
file = source.filename().string().size() > 6
153 ? source.filename().string().substr(
154 0, source.filename().string().size() - 6)
157 std::string num =
"0";
158 std::string one =
file;
160 one =
file +
"-" + num;
163 std::string clinput =
"z-" + one +
".clinput";
164 std::ofstream ofile(clinput);
166 std::string CHK = std::getenv(
"CHK")
175 seedj = std::to_string(
m_seeds.at(0));
179 std::string seedi =
m_seeds.size() < 2
185 std::string rootcproot =
"nono";
186 std::string system =
"i";
187 std::string ext1 =
"-";
188 std::string ext3 =
"-";
189 std::string ext4 =
"-";
190 std::string gefac =
"1";
191 auto safeGetenv = [
this](
const char *envName) -> std::string {
192 const char *env = std::getenv(envName);
198 std::string EPO = safeGetenv(
"EPO");
199 std::string SRCEXT = safeGetenv(
"SRCEXT");
200 std::string HTO = safeGetenv(
"HTO");
201 std::string SRC = safeGetenv(
"SRC");
202 std::string CONF = safeGetenv(
"CONF");
203 std::string OPT = safeGetenv(
"OPT");
204 std::string OPX =
"";
205 if (std::string(OPT) ==
"./") {
206 OPX = std::filesystem::current_path().string() +
"/";
208 OPX = std::move(OPT);
212 <<
"EPO: " << EPO <<
"\n"
213 <<
"SRCEXT: " << SRCEXT <<
"\n"
214 <<
" HTO: " << HTO <<
"\n"
215 <<
" SRC: " << SRC <<
"\n"
216 <<
" OPX: " << OPX <<
"\n"
217 <<
" CHK: " << CHK <<
"\n"
221 ofile <<
"!fname mtr " << CHK <<
"z-" << one <<
".mtr\n";
222 ofile <<
"set seedj " << seedj <<
" set seedi " << seedi <<
"\n";
223 ofile <<
"echo off\n";
224 ofile <<
"rootcproot " << rootcproot <<
"\n";
225 ofile <<
"system " << system <<
"\n";
226 ofile <<
"ext1 " << ext1 <<
"\n";
227 ofile <<
"ext3 " << ext3 <<
"\n";
228 ofile <<
"ext4 " << ext4 <<
"\n";
229 ofile <<
"set gefac " << gefac <<
"\n";
230 ofile <<
"!!!beginoptns spherio !No longer used.\n";
231 ofile <<
"!!!... !See version < 3118 \n";
232 ofile <<
"!!!endoptns spherio !if needed again \n";
233 ofile <<
"fname pathep " << EPO <<
"\n";
234 ofile <<
"!-------HQ--------\n";
235 ofile <<
"fname user1 " << SRCEXT <<
"/HQt/\n";
236 ofile <<
"fname user2 " << HTO <<
"z-" << one <<
".hq\n";
237 ofile <<
"fname user3 " << SRCEXT <<
"/URt/\n";
238 ofile <<
"!-------HQ END--------\n";
239 ofile <<
"fname pathpdf " << SRC <<
"/TPt/\n";
240 ofile <<
"fname histo " << HTO <<
"z-" << one <<
".histo\n";
241 ofile <<
"fname check " << CHK <<
"z-" << one <<
".check\n";
242 ofile <<
"fname copy " << CHK <<
"z-" << one <<
".copy\n";
243 ofile <<
"fname log " << CHK <<
"z-" << one <<
".log\n";
244 ofile <<
"fname data " << CHK <<
"z-" << one <<
".data\n";
245 ofile <<
"fname initl " << SRC <<
"/KWt/aa.i\n";
246 ofile <<
"fname inidi " << SRC <<
"/TPt/di.i\n";
247 ofile <<
"fname inidr " << SRC <<
"/KWt/dr.i\n";
248 ofile <<
"fname iniev " << SRC <<
"/KWt/ev.i\n";
249 ofile <<
"fname inirj " << SRC <<
"/KWt/rj.i\n";
250 ofile <<
"fname inics " << SRC <<
"/TPt/cs.i\n";
251 ofile <<
"fname inigrv " << SRC <<
"/grv.i\n";
252 ofile <<
"fname partab " << SRCEXT <<
"/YK/ptl6.data\n";
253 ofile <<
"fname dectab " << SRCEXT <<
"/YK/dky6.data\n";
254 ofile <<
"fname hpf " << SRCEXT <<
"/UR/tables.dat \n";
255 ofile <<
"!fqgsjet dat " << EPO << SRC
256 <<
"qgsjet/qgsjet.dat !No longer used.\n";
257 ofile <<
"!fqgsjet ncs " << EPO << SRC
258 <<
"qgsjet/qgsjet.ncs !No longer used.\n";
259 ofile <<
"!fqgsjetII dat " << EPO << SRC
260 <<
"qgsjetII/qgsdat-II-03 !No longer used.\n";
261 ofile <<
"!fqgsjetII ncs " << EPO << SRC
262 <<
"qgsjetII/sectnu-II-03 !No longer used.\n";
263 ofile <<
"nodecay 1220\n";
264 ofile <<
"nodecay -1220\n";
265 ofile <<
"nodecay 120\n";
266 ofile <<
"nodecay -120\n";
267 ofile <<
"nodecay 130\n";
268 ofile <<
"nodecay -130\n";
269 ofile <<
"nodecay -20\n";
270 ofile <<
"nodecay 14\n";
271 ofile <<
"nodecay -14\n";
272 ofile <<
"nodecay 16\n";
273 ofile <<
"nodecay -16\n";
274 ofile <<
"echo on\n";
275 ofile <<
"input " << CONF <<
"/parbf.i\n";
276 ofile <<
"input " << OPX <<
"z-" << one <<
".optns\n";
277 ofile <<
"input " << SRC <<
"/KWn/paraf.i\n";
278 ofile <<
"input " << CONF <<
"/partx.i\n";
279 ofile <<
"runprogram\n";
280 ofile <<
"stopprogram\n";
290 epos_rndm_stream =
"EPOS4";
293 writer = std::make_shared<HepMC3::WriterEPOS>(
"foo");
304 for (
int k = 1; k <= currentnumberOfEnergyValues; k++) {
311 return StatusCode::SUCCESS;
319 const EventContext &ctx = Gaudi::Hive::currentContext();
321 ctx.eventID().event_number(),
m_dsid,
323 p_rndmEngine->setSeeds(seeds, 0);
325 const long *s = p_rndmEngine->getSeeds();
332 return StatusCode::SUCCESS;
346 return StatusCode::SUCCESS;
352 std::dynamic_pointer_cast<HepMC3::WriterEPOS>(
writer)->current_event();
355 e.set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
357 <<
" | particles: " << e.particles().size()
358 <<
" | vertices: " << e.vertices().size());
361 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[])