diff --git a/MC/config/examples/epos4/generator_EPOS4.C b/MC/config/examples/epos4/generator_EPOS4.C index 6d08a7b19..1dd5cd3fd 100644 --- a/MC/config/examples/epos4/generator_EPOS4.C +++ b/MC/config/examples/epos4/generator_EPOS4.C @@ -43,19 +43,26 @@ FairGenerator* generateEPOS4(const std::string &name, const int& nEvents) buffer << line << "\n"; } file.close(); + auto gen = new GeneratorEPOS4(); + auto ¶m0 = o2::eventgen::GeneratorFileOrCmdParam::Instance(); + auto ¶m = o2::eventgen::GeneratorHepMCParam::Instance(); + auto &conf = o2::conf::SimConfig::Instance(); + // Randomise seed (useful for multiple instances of the generator) + int randomSeed = gRandom->Integer(conf.getStartSeed()); // Write the updated content back to a file in the current directory - std::ofstream outFile("cfg.optns"); + std::string optnsFileName(Form("cfg%d.optns", randomSeed)); + std::ofstream outFile(optnsFileName); outFile << buffer.str(); if (!found) { outFile << "set nfull " + std::to_string(nEvents); } outFile.close(); - auto gen = new GeneratorEPOS4(); - auto& param0 = o2::eventgen::GeneratorFileOrCmdParam::Instance(); - auto& param = o2::eventgen::GeneratorHepMCParam::Instance(); - auto& conf = o2::conf::SimConfig::Instance(); + optnsFileName = optnsFileName.substr(0, optnsFileName.find_last_of('.')); // remove the .optns extension // setup the HepMC generator to run with automatic FIFOs gen->setup(param0, param, conf); + // Replace seed and optns file + gen->setCmd(param0.cmd + " -i " + optnsFileName); + gen->setSeed(randomSeed); return gen; } diff --git a/MC/config/examples/ini/GeneratorEPOS4.ini b/MC/config/examples/ini/GeneratorEPOS4.ini index fabfd6066..abfbb65dd 100644 --- a/MC/config/examples/ini/GeneratorEPOS4.ini +++ b/MC/config/examples/ini/GeneratorEPOS4.ini @@ -3,7 +3,7 @@ fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator_EPOS4.C funcName=generateEPOS4("${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator/example.optns", 2147483647) [GeneratorFileOrCmd] -cmd=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/epos.sh -i cfg +cmd=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/epos.sh bMaxSwitch=none # Set to version 2 if EPOS4.0.0 is used diff --git a/MC/config/examples/ini/GeneratorEPOS4HQ.ini b/MC/config/examples/ini/GeneratorEPOS4HQ.ini index de88cd801..f5804d584 100644 --- a/MC/config/examples/ini/GeneratorEPOS4HQ.ini +++ b/MC/config/examples/ini/GeneratorEPOS4HQ.ini @@ -4,7 +4,7 @@ fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator_EPOS4.C funcName=generateEPOS4("${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/generator/examplehq.optns", 2147483647) [GeneratorFileOrCmd] -cmd=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/epos.sh -i cfg +cmd=${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/epos4/epos.sh bMaxSwitch=none [HepMC]