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";
118namespace fs = std::filesystem;
121 fs::path source = filein;
122 fs::path destination = fs::current_path() / fs::path(std::string(
"z-")+source.filename().string());
124 std::ifstream src(source);
125 std::ofstream dst(destination);
128 std::cerr <<
"Error: Cannot open source file.\n";
133 std::cerr <<
"Error: Cannot create destination file.\n";
138 while (std::getline(src, line)) {
141 dst<<
"set ihepmc 1"<<
'\n';
143 std::string
file = source.filename().string().size()>6 ? source.filename().string().substr(0,source.filename().string().size()-6) :
"";
146 std::string one =
file;
148 one =
file +
"-" + num;
151 std::string clinput =
"z-" + one +
".clinput";
152 std::ofstream ofile(clinput);
154 std::string CHK = std::getenv(
"CHK") ? std::getenv(
"CHK") : (std::cerr <<
"Warning: CHK not set\n",
"");
155 std::string seedi = std::to_string(
m_seeds.at(0));
156 std::string seedj = std::to_string(
m_seeds.at(1));
157 std::string rootcproot =
"nono";
158 std::string system =
"i";
159 std::string ext1 =
"-";
160 std::string ext3 =
"-";
161 std::string ext4 =
"-";
162 std::string gefac =
"1";
163 std::string EPO = std::getenv(
"EPO") ? std::getenv(
"EPO") : (std::cerr <<
"Warning: EPO not set\n",
"");
164 std::string SRCEXT = std::getenv(
"SRCEXT") ? std::getenv(
"SRCEXT") : (std::cerr <<
"Warning: SRCEXT not set\n",
"");
165 std::string HTO = std::getenv(
"HTO") ? std::getenv(
"HTO") : (std::cerr <<
"Warning: HTO not set\n",
"");
166 std::string SRC = std::getenv(
"SRC") ? std::getenv(
"SRC") : (std::cerr <<
"Warning: SRC not set\n",
"");
167 std::string CONF = std::getenv(
"CONF") ? std::getenv(
"CONF") : (std::cerr <<
"Warning: CONF not set\n",
"");
168 std::string OPT = std::getenv(
"OPT") ? std::getenv(
"OPT") : (std::cerr <<
"Warning: OPT not set\n",
"");
170 if (std::string(OPT) ==
"./") {
171 OPX = std::filesystem::current_path().string() +
"/";
173 OPX = std::move(OPT);
176 ofile <<
"!fname mtr " << CHK <<
"z-" << one <<
".mtr\n";
177 ofile <<
"set seedj " << seedj <<
" set seedi " << seedi <<
"\n";
178 ofile <<
"echo off\n";
179 ofile <<
"rootcproot " << rootcproot <<
"\n";
180 ofile <<
"system " << system <<
"\n";
181 ofile <<
"ext1 " << ext1 <<
"\n";
182 ofile <<
"ext3 " << ext3 <<
"\n";
183 ofile <<
"ext4 " << ext4 <<
"\n";
184 ofile <<
"set gefac " << gefac <<
"\n";
185 ofile <<
"!!!beginoptns spherio !No longer used.\n";
186 ofile <<
"!!!... !See version < 3118 \n";
187 ofile <<
"!!!endoptns spherio !if needed again \n";
188 ofile <<
"fname pathep " << EPO <<
"\n";
189 ofile <<
"!-------HQ--------\n";
190 ofile <<
"fname user1 " << SRCEXT <<
"/HQt/\n";
191 ofile <<
"fname user2 " << HTO <<
"z-" << one <<
".hq\n";
192 ofile <<
"fname user3 " << SRCEXT <<
"/URt/\n";
193 ofile <<
"!-------HQ END--------\n";
194 ofile <<
"fname pathpdf " << SRC <<
"/TPt/\n";
195 ofile <<
"fname histo " << HTO <<
"z-" << one <<
".histo\n";
196 ofile <<
"fname check " << CHK <<
"z-" << one <<
".check\n";
197 ofile <<
"fname copy " << CHK <<
"z-" << one <<
".copy\n";
198 ofile <<
"fname log " << CHK <<
"z-" << one <<
".log\n";
199 ofile <<
"fname data " << CHK <<
"z-" << one <<
".data\n";
200 ofile <<
"fname initl " << SRC <<
"/KWt/aa.i\n";
201 ofile <<
"fname inidi " << SRC <<
"/TPt/di.i\n";
202 ofile <<
"fname inidr " << SRC <<
"/KWt/dr.i\n";
203 ofile <<
"fname iniev " << SRC <<
"/KWt/ev.i\n";
204 ofile <<
"fname inirj " << SRC <<
"/KWt/rj.i\n";
205 ofile <<
"fname inics " << SRC <<
"/TPt/cs.i\n";
206 ofile <<
"fname inigrv " << SRC <<
"/grv.i\n";
207 ofile <<
"fname partab " << SRCEXT <<
"/YK/ptl6.data\n";
208 ofile <<
"fname dectab " << SRCEXT <<
"/YK/dky6.data\n";
209 ofile <<
"fname hpf " << SRCEXT <<
"/UR/tables.dat \n";
210 ofile <<
"!fqgsjet dat " << EPO << SRC <<
"qgsjet/qgsjet.dat !No longer used.\n";
211 ofile <<
"!fqgsjet ncs " << EPO << SRC <<
"qgsjet/qgsjet.ncs !No longer used.\n";
212 ofile <<
"!fqgsjetII dat " << EPO << SRC <<
"qgsjetII/qgsdat-II-03 !No longer used.\n";
213 ofile <<
"!fqgsjetII ncs " << EPO << SRC <<
"qgsjetII/sectnu-II-03 !No longer used.\n";
214 ofile <<
"nodecay 1220\n";
215 ofile <<
"nodecay -1220\n";
216 ofile <<
"nodecay 120\n";
217 ofile <<
"nodecay -120\n";
218 ofile <<
"nodecay 130\n";
219 ofile <<
"nodecay -130\n";
220 ofile <<
"nodecay -20\n";
221 ofile <<
"nodecay 14\n";
222 ofile <<
"nodecay -14\n";
223 ofile <<
"nodecay 16\n";
224 ofile <<
"nodecay -16\n";
225 ofile <<
"echo on\n";
226 ofile <<
"input " << CONF <<
"/parbf.i\n";
227 ofile <<
"input " << OPX <<
"z-" << one <<
".optns\n";
228 ofile <<
"input " << SRC <<
"/KWn/paraf.i\n";
229 ofile <<
"input " << CONF <<
"/partx.i\n";
230 ofile <<
"runprogram\n";
231 ofile <<
"stopprogram\n";
241 epos_rndm_stream =
"EPOS4";
244 std::string in(
"someinputfoo.txt");
245 writer = std::make_shared<HepMC3::WriterEPOS>(
"foo");
258 for (
int k=1; k<=currentnumberOfEnergyValues; k++) {
265 return StatusCode::SUCCESS;
273 const EventContext& ctx = Gaudi::Hive::currentContext();
275 p_rndmEngine->setSeeds(seeds, 0);
278 const long *s = p_rndmEngine->getSeeds();
284 return StatusCode::SUCCESS;
298 return StatusCode::SUCCESS;
304 auto e = std::dynamic_pointer_cast<HepMC3::WriterEPOS>(
writer)->current_event();
307 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 genInitialize()
For initializing the generator, if required.
virtual StatusCode fillEvt(HepMC::GenEvent *evt)
For filling the HepMC event object.
std::string create_file(const std::string &filein)
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
Epos4(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< long int > m_seeds
virtual StatusCode genFinalize()
For finalising the generator, if required.
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[])