13#include "GaudiKernel/MsgStream.h"
14#include "CLHEP/Random/RandFlat.h"
21#include "HepMC3/Writer.h"
22#include "HepMC3/GenEvent.h"
43 size_t len = std::strlen(filename);
44 if (len > 1000) len = 1000;
46 std::memcpy(
jobfname_.fnjob, filename, len);
47 for (
size_t i = len; i < 1000; ++i) {
54static std::string epos_rndm_stream =
"EPOS4_INIT";
55static CLHEP::HepRandomEngine* p_rndmEngine{};
58extern std::shared_ptr<HepMC3::Writer>
writer;
62 WriterEPOS([[maybe_unused]]
const std::string& filename, std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
63 set_run_info(std::move(
run));
65 WriterEPOS([[maybe_unused]] std::ostream& stream, std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
66 set_run_info(std::move(
run));
68 WriterEPOS([[maybe_unused]] std::shared_ptr<std::ostream> s_stream, std::shared_ptr<GenRunInfo>
run = std::shared_ptr<GenRunInfo>()) {
69 set_run_info(std::move(
run));
111 epos_rndm_stream =
"EPOS4_INIT";
119namespace fs = std::filesystem;
122 if (filein.size() < 6 || filein.compare(filein.size() - 6, 6,
".optns") != 0) {
123 std::cerr <<
"Error: Input file name: " << filein <<
" does not end with \".optns\"\n";
127 fs::path source = filein;
128 fs::path destination = fs::current_path() / fs::path(std::string(
"z-") + source.filename().string());
131 std::ifstream src(source);
132 std::ofstream dst(destination);
135 std::cerr <<
"Error: Cannot open source file: " << source <<
"\n";
140 std::cerr <<
"Error: Cannot create destination file: " << destination <<
"\n";
145 while (std::getline(src, line)) {
148 dst <<
"set ihepmc 1" <<
'\n';
150 std::string
file = source.filename().string().size() > 6 ? source.filename().string().substr(0, source.filename().string().size() - 6 ) :
"";
152 std::string num =
"0";
153 std::string one =
file;
155 one =
file +
"-" + num;
158 std::string clinput =
"z-" + one +
".clinput";
159 std::ofstream ofile(clinput);
161 std::string CHK = std::getenv(
"CHK") ? std::getenv(
"CHK") : (std::cerr <<
"Warning: CHK not set\n",
"");
162 if (
m_seeds.size() < 2) std::cerr <<
"Warning: m_seeds should contain at least 2 elements\n";
163 std::string seedi =
m_seeds.size() < 1 ?
"111111111" : std::to_string(
m_seeds.at(0));
164 std::string seedj =
m_seeds.size() < 2 ?
"222222222" : std::to_string(
m_seeds.at(1));
165 std::string rootcproot =
"nono";
166 std::string system =
"i";
167 std::string ext1 =
"-";
168 std::string ext3 =
"-";
169 std::string ext4 =
"-";
170 std::string gefac =
"1";
171 std::string EPO = std::getenv(
"EPO") ? std::getenv(
"EPO") : (std::cerr <<
"Warning: EPO not set\n",
"");
172 std::string SRCEXT = std::getenv(
"SRCEXT") ? std::getenv(
"SRCEXT") : (std::cerr <<
"Warning: SRCEXT not set\n",
"");
173 std::string HTO = std::getenv(
"HTO") ? std::getenv(
"HTO") : (std::cerr <<
"Warning: HTO not set\n",
"");
174 std::string SRC = std::getenv(
"SRC") ? std::getenv(
"SRC") : (std::cerr <<
"Warning: SRC not set\n",
"");
175 std::string CONF = std::getenv(
"CONF") ? std::getenv(
"CONF") : (std::cerr <<
"Warning: CONF not set\n",
"");
176 std::string OPT = std::getenv(
"OPT") ? std::getenv(
"OPT") : (std::cerr <<
"Warning: OPT not set\n",
"");
177 std::string OPX =
"";
178 if (std::string(OPT) ==
"./") {
179 OPX = std::filesystem::current_path().string() +
"/";
181 OPX = std::move(OPT);
184 ofile <<
"!fname mtr " << CHK <<
"z-" << one <<
".mtr\n";
185 ofile <<
"set seedj " << seedj <<
" set seedi " << seedi <<
"\n";
186 ofile <<
"echo off\n";
187 ofile <<
"rootcproot " << rootcproot <<
"\n";
188 ofile <<
"system " << system <<
"\n";
189 ofile <<
"ext1 " << ext1 <<
"\n";
190 ofile <<
"ext3 " << ext3 <<
"\n";
191 ofile <<
"ext4 " << ext4 <<
"\n";
192 ofile <<
"set gefac " << gefac <<
"\n";
193 ofile <<
"!!!beginoptns spherio !No longer used.\n";
194 ofile <<
"!!!... !See version < 3118 \n";
195 ofile <<
"!!!endoptns spherio !if needed again \n";
196 ofile <<
"fname pathep " << EPO <<
"\n";
197 ofile <<
"!-------HQ--------\n";
198 ofile <<
"fname user1 " << SRCEXT <<
"/HQt/\n";
199 ofile <<
"fname user2 " << HTO <<
"z-" << one <<
".hq\n";
200 ofile <<
"fname user3 " << SRCEXT <<
"/URt/\n";
201 ofile <<
"!-------HQ END--------\n";
202 ofile <<
"fname pathpdf " << SRC <<
"/TPt/\n";
203 ofile <<
"fname histo " << HTO <<
"z-" << one <<
".histo\n";
204 ofile <<
"fname check " << CHK <<
"z-" << one <<
".check\n";
205 ofile <<
"fname copy " << CHK <<
"z-" << one <<
".copy\n";
206 ofile <<
"fname log " << CHK <<
"z-" << one <<
".log\n";
207 ofile <<
"fname data " << CHK <<
"z-" << one <<
".data\n";
208 ofile <<
"fname initl " << SRC <<
"/KWt/aa.i\n";
209 ofile <<
"fname inidi " << SRC <<
"/TPt/di.i\n";
210 ofile <<
"fname inidr " << SRC <<
"/KWt/dr.i\n";
211 ofile <<
"fname iniev " << SRC <<
"/KWt/ev.i\n";
212 ofile <<
"fname inirj " << SRC <<
"/KWt/rj.i\n";
213 ofile <<
"fname inics " << SRC <<
"/TPt/cs.i\n";
214 ofile <<
"fname inigrv " << SRC <<
"/grv.i\n";
215 ofile <<
"fname partab " << SRCEXT <<
"/YK/ptl6.data\n";
216 ofile <<
"fname dectab " << SRCEXT <<
"/YK/dky6.data\n";
217 ofile <<
"fname hpf " << SRCEXT <<
"/UR/tables.dat \n";
218 ofile <<
"!fqgsjet dat " << EPO << SRC <<
"qgsjet/qgsjet.dat !No longer used.\n";
219 ofile <<
"!fqgsjet ncs " << EPO << SRC <<
"qgsjet/qgsjet.ncs !No longer used.\n";
220 ofile <<
"!fqgsjetII dat " << EPO << SRC <<
"qgsjetII/qgsdat-II-03 !No longer used.\n";
221 ofile <<
"!fqgsjetII ncs " << EPO << SRC <<
"qgsjetII/sectnu-II-03 !No longer used.\n";
222 ofile <<
"nodecay 1220\n";
223 ofile <<
"nodecay -1220\n";
224 ofile <<
"nodecay 120\n";
225 ofile <<
"nodecay -120\n";
226 ofile <<
"nodecay 130\n";
227 ofile <<
"nodecay -130\n";
228 ofile <<
"nodecay -20\n";
229 ofile <<
"nodecay 14\n";
230 ofile <<
"nodecay -14\n";
231 ofile <<
"nodecay 16\n";
232 ofile <<
"nodecay -16\n";
233 ofile <<
"echo on\n";
234 ofile <<
"input " << CONF <<
"/parbf.i\n";
235 ofile <<
"input " << OPX <<
"z-" << one <<
".optns\n";
236 ofile <<
"input " << SRC <<
"/KWn/paraf.i\n";
237 ofile <<
"input " << CONF <<
"/partx.i\n";
238 ofile <<
"runprogram\n";
239 ofile <<
"stopprogram\n";
249 epos_rndm_stream =
"EPOS4";
252 writer = std::make_shared<HepMC3::WriterEPOS>(
"foo");
263 for (
int k=1; k<=currentnumberOfEnergyValues; k++) {
270 return StatusCode::SUCCESS;
278 const EventContext& ctx = Gaudi::Hive::currentContext();
280 p_rndmEngine->setSeeds(seeds, 0);
282 const long *s = p_rndmEngine->getSeeds();
288 return StatusCode::SUCCESS;
302 return StatusCode::SUCCESS;
308 auto e = std::dynamic_pointer_cast<HepMC3::WriterEPOS>(
writer)->current_event();
311 return StatusCode::SUCCESS;
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[])