42 #include "CLHEP/Random/engineIDulong.h" 43 #include "CLHEP/Random/JamesRandom.h" 44 #include "CLHEP/Random/RanecuEngine.h" 45 #include "CLHEP/Random/MixMaxRng.h" 65 saveFileName_(
pset.getUntrackedParameter<
std::
string>(
"saveFileName")),
66 saveFileNameRecorded_(
false),
67 restoreFileName_(
pset.getUntrackedParameter<
std::
string>(
"restoreFileName")),
68 enableChecking_(
pset.getUntrackedParameter<
bool>(
"enableChecking")),
69 eventSeedOffset_(
pset.getUntrackedParameter<unsigned>(
"eventSeedOffset")),
70 verbose_(
pset.getUntrackedParameter<
bool>(
"verbose")) {
71 if (
pset.exists(
"restoreStateTag")) {
84 <<
"restoreFileName and restoreStateLabel were set to nonempty values\n" 85 <<
"which is illegal. It is impossible to restore the random engine\n" 86 <<
"states two different ways in the same process.\n";
93 <<
"The saveFileName parameter must be a simple file name with no path\n" 94 <<
"specification. In the configuration, it was given the value \"" <<
saveFileName_ <<
"\"\n";
101 std::vector<std::string> pSets =
pset.getParameterNamesForType<
ParameterSet>();
102 for (
auto const&
label : pSets) {
106 bool initialSeedExists = modulePSet.
exists(
"initialSeed");
107 bool initialSeedSetExists = modulePSet.
exists(
"initialSeedSet");
109 if (initialSeedExists && initialSeedSetExists) {
111 <<
"both the parameters \"initialSeed\" and \"initialSeedSet\"\n" 112 <<
"have been set in the configuration. You must set one or\n" 113 <<
"the other. It is illegal to set both.\n";
114 }
else if (!initialSeedExists && !initialSeedSetExists) {
116 <<
"neither the parameter \"initialSeed\" nor \"initialSeedSet\"\n" 117 <<
"has been set in the configuration. You must set one or\n" 119 }
else if (initialSeedExists) {
123 }
else if (initialSeedSetExists) {
132 <<
"Random engines of type \"RanecuEngine\" require 2 seeds\n" 133 <<
"be specified with the parameter named \"initialSeedSet\".\n" 134 <<
"Either \"initialSeedSet\" was not in the configuration\n" 135 <<
"or its size was not 2 for the module with label \"" <<
label <<
"\".\n";
140 <<
"The RanecuEngine seeds should be in the range 0 to " <<
maxSeedRanecu <<
".\n" 141 <<
"The seeds passed to the RandomNumberGenerationService from the\n" 142 "configuration file were " 151 <<
"Random engines of type \"HepJamesRandom\", \"TRandom3\" and \"MixMaxRng\" \n" 152 <<
"require exactly 1 seed be specified in the configuration.\n" 153 <<
"There were " <<
initialSeedSet.size() <<
" seeds set for the\n" 154 <<
"module with label \"" <<
label <<
"\".\n";
159 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to " <<
maxSeedHepJames <<
".\n" 160 <<
"The seed passed to the RandomNumberGenerationService from the\n" 161 "configuration file was " 163 <<
"the module with label " <<
label <<
".\n";
168 <<
"The CLHEP::MixMaxRng engine seed should be in the range 0 to " <<
maxSeedTRandom3 <<
".\n" 169 <<
"The seed passed to the RandomNumberGenerationService from the\n" 170 "configuration file was " 172 <<
"the module with label " <<
label <<
".\n";
177 <<
"The CLHEP::MixMaxRng engine seed should be in the range 0 to " <<
maxSeedTRandom3 <<
".\n" 178 <<
"The seed passed to the RandomNumberGenerationService from the\n" 179 "configuration file was " 181 <<
"the module with label " <<
label <<
".\n";
185 <<
"The random engine name, \"" <<
engineName <<
"\", does not correspond to a supported engine.\n" 186 <<
"This engine was configured for the module with label \"" <<
label <<
"\"";
232 <<
"RandomNumberGeneratorService::getEngine\n" 233 "Requested a random number engine from the RandomNumberGeneratorService\n" 234 "while ModuleCallingContext is null or during beginJob or endJob transitions.\n";
240 std::vector<ModuleIDToEngine>::iterator iter =
242 if (iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
245 <<
"\" requested a random number engine from the \n" 246 "RandomNumberGeneratorService, but that module was not configured\n" 247 "for random numbers. An engine is created only if a seed(s) is provided\n" 248 "in the configuration file. Please add the following PSet to the\n" 249 "configuration file for the RandomNumberGeneratorService:\n\n" 253 " initialSeed = cms.untracked.uint32(your_seed),\n" 254 " engineName = cms.untracked.string('TRandom3')\n" 256 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 257 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
259 return *iter->labelAndEngine()->engine();
266 <<
"RandomNumberGeneratorService::getEngine\n" 267 "Requested a random number engine from the RandomNumberGeneratorService\n" 268 "while ModuleCallingContext is null or during beginJob or endJob transitions.\n";
274 std::vector<ModuleIDToEngine>::iterator iter =
276 if (iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
279 <<
"\" requested a random number engine from the \n" 280 "RandomNumberGeneratorService, but that module was not configured\n" 281 "for random numbers. An engine is created only if a seed(s) is provided\n" 282 "in the configuration file. Please add the following PSet to the\n" 283 "configuration file for the RandomNumberGeneratorService:\n\n" 287 " initialSeed = cms.untracked.uint32(your_seed),\n" 288 " engineName = cms.untracked.string('TRandom3')\n" 290 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 291 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
293 return *iter->labelAndEngine()->engine();
312 <<
"RandomNumberGeneratorService::mySeed()\n" 313 "Requested a random number seed from the RandomNumberGeneratorService\n" 314 "while ModuleCallingContext is null or during beginJob or endJob transitions.\n";
322 <<
"The module with label \"" <<
label 323 <<
"\" requested a random number seed from the \n" 324 "RandomNumberGeneratorService, but that module was not configured\n" 325 "for random numbers. An engine is created only if a seed(s) is provided\n" 326 "in the configuration file. Please add the following PSet to the\n" 327 "configuration file for the RandomNumberGeneratorService:\n\n" 331 " initialSeed = cms.untracked.uint32(your_seed),\n" 332 " engineName = cms.untracked.string('TRandom3')\n" 334 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 335 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
337 return iter->second.seeds()[0];
351 desc.addUntracked<
bool>(
"enableChecking",
false);
352 desc.addUntracked<
unsigned>(
"eventSeedOffset", 0
U);
353 desc.addUntracked<
bool>(
"verbose",
false);
356 val.addOptionalUntracked<std::uint32_t>(
"initialSeed");
357 val.addOptionalUntracked<std::vector<std::uint32_t> >(
"initialSeedSet");
361 wnode.setComment(
"The name of each ParameterSet will be the associated module label.");
364 descriptions.
add(
"RandomNumberGeneratorService",
desc);
386 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n" 387 <<
"to run replay using a text file to input the random engine states and\n" 388 <<
"the number of streams is greater than 1. Either set the\n" 389 <<
"parameter named \"restoreFileName\" in the RandomNumberGeneratorService\n" 390 <<
"to the empty string or set the parameter \"numberOfStreams\" in the top\n" 391 <<
"level options parameter set to 1. (Probably these are the default values\n" 392 <<
"and just not setting the parameters will also work)\n";
404 for (
unsigned int iStream = 0; iStream <
nStreams_; ++iStream) {
405 unsigned int seedOffset = iStream;
408 outFiles_[iStream] = std::make_shared<std::ofstream>();
411 for (
unsigned int iLumi = 0; iLumi < nConcurrentLumis; ++iLumi) {
469 bool expected =
false;
473 reportSvc->reportRandomStateFile(
fullName);
479 std::vector<RandomEngineState>
const& iStates) {
555 os <<
"\n\nRandomNumberGeneratorService dump\n\n";
557 os <<
" Contents of seedsAndNameMap (label moduleID engineType seeds)\n";
559 os <<
" " <<
entry.first <<
" " <<
entry.second.moduleID() <<
" " <<
entry.second.engineName();
560 for (
auto val :
entry.second.seeds()) {
575 os <<
"\n streamEngines_\n";
576 unsigned int iStream = 0;
578 os <<
" Stream " << iStream <<
"\n";
579 for (
auto const&
i :
k) {
580 os <<
" " <<
i.label();
581 for (
auto const&
j :
i.seeds()) {
584 os <<
" " <<
i.engine()->name();
585 if (
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
586 os <<
" " <<
i.engine()->getSeed();
587 }
else if (
i.engine()->name() ==
std::string(
"MixMaxRng")) {
588 os <<
" " <<
i.engine()->getSeed();
590 os <<
" engine does not know seeds";
596 os <<
"\n lumiEngines_\n";
597 unsigned int iLumi = 0;
599 os <<
" lumiIndex " << iLumi <<
"\n";
600 for (
auto const&
i :
k) {
601 os <<
" " <<
i.label();
602 for (
auto const&
j :
i.seeds()) {
605 os <<
" " <<
i.engine()->name();
606 if (
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
607 os <<
" " <<
i.engine()->getSeed();
608 }
else if (
i.engine()->name() ==
std::string(
"MixMaxRng")) {
609 os <<
" " <<
i.engine()->getSeed();
611 os <<
" engine does not know seeds";
624 std::vector<ModuleIDToEngine>::iterator iter =
626 if (iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
628 iter->setEngineState(labelAndEngine->
engine()->put());
638 std::vector<ModuleIDToEngine>::iterator iter =
640 if (iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
642 if (iter->engineState() != labelAndEngine->
engine()->put()) {
644 <<
"It is illegal to generate random numbers during beginStream, endStream,\n" 645 "beginRun, endRun, beginLumi, endLumi because that makes it very difficult\n" 646 "to replay the processing of individual events. Random numbers were\n" 647 "generated during one of these methods for the module with class name\n\"" 650 "and module label \"" 662 <<
"In the configuration for the RandomNumberGeneratorService the\n" 663 <<
"restoreStateTag contains the current process which is illegal.\n" 664 <<
"The process name in the replay process should have been changed\n" 665 <<
"to be different than the original process name and the restoreStateTag\n" 666 <<
"should contain either the original process name or an empty process name.\n";
675 <<
"The RandomNumberGeneratorService is trying to restore\n" 676 <<
"the state of the random engines by reading a product from\n" 678 <<
"It could not find the product.\n" 679 <<
"Either the product in the LuminosityBlock was dropped or\n" 680 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
693 <<
"The RandomNumberGeneratorService is trying to restore\n" 694 <<
"the state of the random engines by reading a product from\n" 696 <<
"It could not find the product.\n" 697 <<
"Either the product in the Event was dropped or\n" 698 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
705 std::vector<RandomEngineState>&
cache) {
706 cache.resize(engines.size());
707 std::vector<RandomEngineState>::iterator
state =
cache.begin();
709 for (std::vector<LabelAndEngine>::const_iterator iter = engines.begin(); iter != engines.end(); ++iter, ++
state) {
712 state->setSeed(iter->seeds());
714 std::vector<unsigned long> stateL = iter->engine()->put();
715 state->clearStateVector();
716 state->reserveStateVector(stateL.size());
717 for (
auto element : stateL) {
718 state->push_back_stateVector(static_cast<std::uint32_t>(element));
724 std::vector<LabelAndEngine>& engines) {
725 std::vector<LabelAndEngine>::iterator labelAndEngine = engines.begin();
726 for (
auto const& cachedState :
cache) {
727 std::string const& engineLabel = cachedState.getLabel();
729 std::vector<std::uint32_t>
const& engineState = cachedState.getState();
730 std::vector<unsigned long> engineStateL;
731 engineStateL.reserve(engineState.size());
732 for (
auto const&
value : engineState) {
733 engineStateL.push_back(static_cast<unsigned long>(
value));
736 std::vector<std::uint32_t>
const& engineSeeds = cachedState.getSeed();
737 std::vector<long> engineSeedsL;
738 engineSeedsL.reserve(engineSeeds.size());
739 for (
auto const&
val : engineSeeds) {
740 long seedL =
static_cast<long>(
val);
741 engineSeedsL.push_back(seedL);
750 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
754 assert(labelAndEngine != engines.end() && engineLabel == labelAndEngine->label());
755 std::shared_ptr<CLHEP::HepRandomEngine>
const& engine = labelAndEngine->engine();
759 if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
763 engine->setSeed(engineSeedsL[0], 0);
764 engine->get(engineStateL);
766 labelAndEngine->setSeed(engineSeeds[0], 0);
767 }
else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
771 engine->get(engineStateL);
773 labelAndEngine->setSeed(engineSeeds[0], 0);
774 labelAndEngine->setSeed(engineSeeds[1], 1);
775 }
else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::MixMaxRng>()) {
779 engine->setSeed(engineSeedsL[0], 0);
780 engine->get(engineStateL);
782 labelAndEngine->setSeed(engineSeeds[0], 0);
783 }
else if (engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
787 engine->setSeed(engineSeedsL[0], 0);
788 engine->get(engineStateL);
790 labelAndEngine->setSeed(engineSeeds[0], 0);
795 <<
"The RandomNumberGeneratorService is trying to restore the state\n" 796 "of the random engines. The state in the event indicates an engine\n" 797 "of an unknown type. This should not be possible unless you are\n" 798 "running with an old code release on a new file that was created\n" 799 "with a newer release which had new engine types added. In this case\n" 800 "the only solution is to use a newer release. In any other case, notify\n" 801 "the EDM developers because this should not be possible\n";
810 if (typeFromConfig != typeFromEvent) {
812 <<
"The RandomNumberGeneratorService is trying to restore\n" 813 <<
"the state of the random engine for the module \"" << engineLabel <<
"\". An\n" 814 <<
"error was detected because the type of the engine in the\n" 815 <<
"input file and the configuration file do not match.\n" 816 <<
"In the configuration file the type is \"" << typeFromConfig <<
"\".\nIn the input file the type is \"" 817 << typeFromEvent <<
"\". If\n" 818 <<
"you are not generating any random numbers in this module, then\n" 819 <<
"remove the line in the configuration file that gives it\n" 820 <<
"a seed and the error will go away. Otherwise, you must give\n" 821 <<
"this module the same engine type in the configuration file or\n" 822 <<
"stop trying to restore the random engine state.\n";
832 std::stringstream
file;
842 <<
"Unable to open the file \"" <<
file.str() <<
"\" to save the state of the random engines.\n";
846 outFile.seekp(0, std::ios_base::beg);
847 outFile <<
"<RandomEngineStates>\n";
857 outFile <<
"</RandomEngineStates>\n";
863 std::vector<std::uint32_t>
const& seedVector =
state.getSeed();
866 std::vector<std::uint32_t>
const& stateVector =
state.getState();
869 outFile <<
"<ModuleLabel>\n" <<
state.getLabel() <<
"\n</ModuleLabel>\n";
871 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n";
874 outFile <<
"</InitialSeeds>\n";
875 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
885 size_t numItems =
v.size();
886 for (
size_t i = 0;
i < numItems; ++
i) {
887 if (
i != 0 &&
i % 10 == 0)
902 std::vector<RandomEngineState>&
cache) {
908 std::vector<RandomEngineState>&
cache) {
914 std::vector<RandomEngineState>&
cache,
920 <<
"Unable to open the file \"" <<
fileName <<
"\" to restore the random engine states.\n";
927 <<
"Attempting to read file with random number engine states.\n" 928 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 929 <<
"Cannot read the file header word.\n";
931 bool saveToCache =
false;
937 std::vector<RandomEngineState>&
cache,
944 std::vector<std::uint32_t> seedVector;
946 std::vector<std::uint32_t> stateVector;
955 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 956 <<
"Cannot read next field and did not hit the end yet.\n";
960 if (leading ==
std::string(
"</RandomEngineStates>"))
971 saveToCache = (leading == whichStates);
980 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 981 <<
"Cannot read a module label when restoring random engine states.\n";
984 is >> leading >> seedVectorSize >> trailing;
987 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 988 <<
"Cannot read seed vector length when restoring random engine states.\n";
992 if (!is.good() || leading !=
std::string(
"<InitialSeeds>")) {
994 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 995 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1000 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1001 <<
"The number of seeds exceeds 64K.\n";
1007 if (!is.good() || trailing !=
std::string(
"</InitialSeeds>")) {
1009 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1010 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
1013 is >> leading >> stateVectorSize >> trailing;
1014 if (!is.good() || leading !=
std::string(
"<FullStateLength>") || trailing !=
std::string(
"</FullStateLength>")) {
1016 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1017 <<
"Cannot read state vector length when restoring random engine states.\n";
1021 if (!is.good() || leading !=
std::string(
"<FullState>")) {
1023 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1024 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1029 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1030 <<
"The number of states exceeds 64K.\n";
1033 readVector(is, stateVectorSize, stateVector);
1036 if (!is.good() || trailing !=
std::string(
"</FullState>")) {
1038 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1039 <<
"Cannot read end of FullState when restoring random engine states.\n";
1045 std::vector<RandomEngineState>::iterator
state =
1049 if (seedVector.size() !=
state->getSeed().size() || stateVector.size() !=
state->getState().size()) {
1051 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1052 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1054 state->setSeed(seedVector);
1055 state->setState(stateVector);
1063 v.reserve(numItems);
1065 for (
unsigned i = 0;
i < numItems; ++
i) {
1069 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1070 <<
"Cannot read vector when restoring random engine states.\n";
1077 unsigned int seedOffset,
1078 unsigned int eventSeedOffset,
1079 std::vector<ModuleIDToEngine>& moduleIDVector) {
1086 unsigned int moduleID =
i.second.moduleID();
1092 if (
name ==
"RanecuEngine") {
1093 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::RanecuEngine>();
1099 long int seedL =
static_cast<long int>(
seeds[0]);
1101 if (
name ==
"HepJamesRandom") {
1102 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::HepJamesRandom>(seedL);
1104 if (seedOffset != 0 || eventSeedOffset != 0) {
1107 }
else if (
name ==
"MixMaxRng") {
1108 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::MixMaxRng>(seedL);
1110 if (seedOffset != 0 || eventSeedOffset != 0) {
1122 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1125 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<TRandomAdaptor>(seedL);
1127 if (seedOffset != 0 || eventSeedOffset != 0) {
1132 moduleIDVector.emplace_back(&engines.back(), moduleID);
1135 std::sort(moduleIDVector.begin(), moduleIDVector.end());
1141 std::uint32_t offset1,
1142 std::uint32_t offset2) {
1149 std::uint32_t seed0 = (
seeds[0] + offset1) %
mod;
1150 seed0 = (seed0 + offset2) %
mod;
1151 labelAndEngine.
setSeed(seed0, 0);
1154 seedL[0] =
static_cast<long int>(seed0);
1155 seedL[1] =
static_cast<long int>(
seeds[1]);
1156 labelAndEngine.
engine()->setSeeds(seedL, 0);
1165 std::uint32_t seed0 = (
seeds[0] + offset1) %
mod;
1166 seed0 = (seed0 + offset2) %
mod;
1167 labelAndEngine.
setSeed(seed0, 0);
1169 long int seedL =
static_cast<long int>(seed0);
1170 labelAndEngine.
engine()->setSeed(seedL, 0);
1177 std::uint32_t seed0 =
seeds[0];
1178 if ((max32 - seed0) >= offset1) {
1181 seed0 = offset1 - (max32 - seed0) - 1
U;
1183 if ((max32 - seed0) >= offset2) {
1186 seed0 = offset2 - (max32 - seed0) - 1
U;
1188 labelAndEngine.
setSeed(seed0, 0);
1190 long seedL =
static_cast<long>(seed0);
1199 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1200 assert(seed0 == seedu32);
1202 labelAndEngine.
engine()->setSeed(seedL, 0);
void writeStates(std::vector< RandomEngineState > const &v, std::ofstream &outFile)
void preModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
void readVector(std::istream &is, unsigned numItems, std::vector< std::uint32_t > &v)
bool beginJobEndJobActive_
void watchPreallocate(Preallocate::slot_type const &iSlot)
CLHEP::HepRandomEngine & getEngine(StreamID const &streamID) override
Use this engine in event methods.
std::shared_ptr< CLHEP::HepRandomEngine const > engine() const
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
static const std::uint32_t maxSeedRanecu
void watchPostModuleEndStream(PostModuleEndStream::slot_type const &iSlot)
void readFromEvent(Event const &event)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
std::atomic< bool > saveFileNameRecorded_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
unsigned int maxNumberOfStreams() const
void setLabel(const std::string &value)
static ModuleCallingContext const * getCurrentModuleOnThread()
void watchPreModuleDestruction(PreModuleDestruction::slot_type const &iSlot)
void preModuleEndStream(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPostModuleStreamEndLumi(PostModuleStreamEndLumi::slot_type const &iSlot)
void watchPostModuleStreamBeginRun(PostModuleStreamBeginRun::slot_type const &iSlot)
std::string const & moduleName() const
void preModuleConstruction(ModuleDescription const &description)
void postModuleStreamEndRun(StreamContext const &sc, ModuleCallingContext const &mcc)
void postModuleStreamCheck(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPreModuleBeginStream(PreModuleBeginStream::slot_type const &iSlot)
void preModuleDestruction(ModuleDescription const &description)
ModuleDescription const * moduleDescription() const noexcept
void resetEngineSeeds(LabelAndEngine &labelAndEngine, std::string const &engineName, VUint32 const &seeds, std::uint32_t offset1, std::uint32_t offset2)
void readFromLuminosityBlock(LuminosityBlock const &lumi)
void preModuleBeginStream(StreamContext const &sc, ModuleCallingContext const &mcc)
edm::InputTag restoreStateTag_
void postModuleStreamBeginRun(StreamContext const &sc, ModuleCallingContext const &mcc)
void setSeed(std::uint32_t v, unsigned int index)
void snapShot(std::vector< LabelAndEngine > const &engines, std::vector< RandomEngineState > &cache)
void setLumiCache(LuminosityBlockIndex, std::vector< RandomEngineState > const &iStates) override
std::unique_ptr< CLHEP::HepRandomEngine > cloneEngine(CLHEP::HepRandomEngine const &)
std::string saveFileName_
T getUntrackedParameter(std::string const &, T const &) const
void postModuleEndStream(StreamContext const &sc, ModuleCallingContext const &mcc)
std::vector< std::vector< ModuleIDToEngine > > streamModuleIDToEngine_
void saveStatesToFile(std::string const &fileName, StreamID const &streamID, LuminosityBlockIndex const &lumiIndex)
RandomNumberGeneratorService(ParameterSet const &pset, ActivityRegistry &activityRegistry)
void preModuleStreamBeginLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > outFiles_
~RandomNumberGeneratorService() override
void createEnginesInVector(std::vector< LabelAndEngine > &engines, unsigned int seedOffset, unsigned int eventSeedOffset, std::vector< ModuleIDToEngine > &moduleIDVector)
bool readEngineState(std::istream &is, std::vector< RandomEngineState > &cache, std::string const &whichStates, bool &saveToCache)
void preModuleStreamBeginRun(StreamContext const &sc, ModuleCallingContext const &mcc)
StreamID const & streamID() const
static const std::uint32_t maxSeedTRandom3
void print(std::ostream &os) const override
For debugging.
std::vector< std::vector< LabelAndEngine > > streamEngines_
std::uint32_t eventSeedOffset_
std::vector< std::vector< RandomEngineState > > eventCache_
std::vector< RandomEngineState > const & getEventCache(StreamID const &) const override
void readStatesFromFile(std::string const &fileName, std::vector< RandomEngineState > &cache, std::string const &whichStates)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void readEventStatesFromTextFile(std::string const &fileName, std::vector< RandomEngineState > &cache)
std::vector< std::vector< RandomEngineState > > lumiCache_
std::vector< RandomEngineState > const & getLumiCache(LuminosityBlockIndex const &) const override
These two are used by the RandomEngineStateProducer.
static const std::vector< std::uint32_t >::size_type maxStates
void watchPostModuleStreamEndRun(PostModuleStreamEndRun::slot_type const &iSlot)
static constexpr unsigned int kInvalid
void preModuleStreamEndRun(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPreModuleStreamBeginLumi(PreModuleStreamBeginLumi::slot_type const &iSlot)
std::uint32_t mySeed() const override
void preallocate(SystemBounds const &)
void watchPostModuleBeginStream(PostModuleBeginStream::slot_type const &iSlot)
std::vector< std::uint32_t > VUint32
void watchPostModuleStreamBeginLumi(PostModuleStreamBeginLumi::slot_type const &iSlot)
void watchPreModuleStreamEndLumi(PreModuleStreamEndLumi::slot_type const &iSlot)
void watchPreModuleStreamBeginRun(PreModuleStreamBeginRun::slot_type const &iSlot)
edm::InputTag restoreStateBeginLumiTag_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void watchPreModuleEndStream(PreModuleEndStream::slot_type const &iSlot)
void consumes(ConsumesCollector &&iC) const override
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
void watchPreEndJob(PreEndJob::slot_type const &iSlot)
std::string constructSaveFileName() const
void postModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
static std::string const emptyString("")
void setEventCache(StreamID, std::vector< RandomEngineState > const &iStates) override
char data[epos_bytes_allocation]
void postEventRead(Event const &event) override
void watchPreModuleStreamEndRun(PreModuleStreamEndRun::slot_type const &iSlot)
void writeVector(VUint32 const &v, std::ofstream &outFile)
std::string restoreFileName_
static const std::vector< std::uint32_t >::size_type maxSeeds
void readLumiStatesFromTextFile(std::string const &fileName, std::vector< RandomEngineState > &cache)
std::unique_ptr< CLHEP::HepRandomEngine > cloneEngine(LuminosityBlockIndex const &) override
unsigned int value() const
void restoreFromCache(std::vector< RandomEngineState > const &cache, std::vector< LabelAndEngine > &engines)
std::vector< std::vector< LabelAndEngine > > lumiEngines_
unsigned int maxNumberOfConcurrentLuminosityBlocks() const
void postModuleBeginStream(StreamContext const &sc, ModuleCallingContext const &mcc)
void checkEngineType(std::string const &typeFromConfig, std::string const &typeFromEvent, std::string const &engineLabel) const
std::string const & moduleLabel() const
T mod(const T &a, const T &b)
std::map< std::string, SeedsAndName > seedsAndNameMap_
std::vector< std::vector< ModuleIDToEngine > > lumiModuleIDToEngine_
void preModuleStreamCheck(StreamContext const &sc, ModuleCallingContext const &mcc)
static const std::uint32_t maxSeedHepJames
void preBeginLumi(LuminosityBlock const &lumi) override
void postModuleStreamBeginLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
void preBeginJob(PathsAndConsumesOfModulesBase const &, ProcessContext const &)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal