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 <<
"\"";
225 if (mcc ==
nullptr) {
227 <<
"RandomNumberGeneratorService::getEngine\n" 228 "Requested a random number engine from the RandomNumberGeneratorService\n" 229 "when no module was active. ModuleCallingContext is null\n";
235 std::vector<ModuleIDToEngine>::iterator iter =
237 if (iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
240 <<
"\" requested a random number engine from the \n" 241 "RandomNumberGeneratorService, but that module was not configured\n" 242 "for random numbers. An engine is created only if a seed(s) is provided\n" 243 "in the configuration file. Please add the following PSet to the\n" 244 "configuration file for the RandomNumberGeneratorService:\n\n" 248 " initialSeed = cms.untracked.uint32(your_seed),\n" 249 " engineName = cms.untracked.string('TRandom3')\n" 251 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 252 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
254 return *iter->labelAndEngine()->engine();
259 if (mcc ==
nullptr) {
261 <<
"RandomNumberGeneratorService::getEngine\n" 262 "Requested a random number engine from the RandomNumberGeneratorService\n" 263 "when no module was active. ModuleCallingContext is null\n";
269 std::vector<ModuleIDToEngine>::iterator iter =
271 if (iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
274 <<
"\" requested a random number engine from the \n" 275 "RandomNumberGeneratorService, but that module was not configured\n" 276 "for random numbers. An engine is created only if a seed(s) is provided\n" 277 "in the configuration file. Please add the following PSet to the\n" 278 "configuration file for the RandomNumberGeneratorService:\n\n" 282 " initialSeed = cms.untracked.uint32(your_seed),\n" 283 " engineName = cms.untracked.string('TRandom3')\n" 285 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 286 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
288 return *iter->labelAndEngine()->engine();
305 if (mcc ==
nullptr) {
307 <<
"RandomNumberGeneratorService::getEngine()\n" 308 "Requested a random number engine from the RandomNumberGeneratorService\n" 309 "from an unallowed transition. ModuleCallingContext is null\n";
317 <<
"The module with label \"" <<
label 318 <<
"\" requested a random number seed from the \n" 319 "RandomNumberGeneratorService, but that module was not configured\n" 320 "for random numbers. An engine is created only if a seed(s) is provided\n" 321 "in the configuration file. Please add the following PSet to the\n" 322 "configuration file for the RandomNumberGeneratorService:\n\n" 326 " initialSeed = cms.untracked.uint32(your_seed),\n" 327 " engineName = cms.untracked.string('TRandom3')\n" 329 "where you replace \"your_seed\" with a number and add a comma if necessary\n" 330 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
332 return iter->second.seeds()[0];
346 desc.addUntracked<
bool>(
"enableChecking",
false);
347 desc.addUntracked<
unsigned>(
"eventSeedOffset", 0
U);
348 desc.addUntracked<
bool>(
"verbose",
false);
351 val.addOptionalUntracked<std::uint32_t>(
"initialSeed");
352 val.addOptionalUntracked<std::vector<std::uint32_t> >(
"initialSeedSet");
356 wnode.setComment(
"The name of each ParameterSet will be the associated module label.");
359 descriptions.
add(
"RandomNumberGeneratorService",
desc);
381 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n" 382 <<
"to run replay using a text file to input the random engine states and\n" 383 <<
"the number of streams is greater than 1. Either set the\n" 384 <<
"parameter named \"restoreFileName\" in the RandomNumberGeneratorService\n" 385 <<
"to the empty string or set the parameter \"numberOfStreams\" in the top\n" 386 <<
"level options parameter set to 1. (Probably these are the default values\n" 387 <<
"and just not setting the parameters will also work)\n";
399 for (
unsigned int iStream = 0; iStream <
nStreams_; ++iStream) {
400 unsigned int seedOffset = iStream;
403 outFiles_[iStream] = std::make_shared<std::ofstream>();
406 for (
unsigned int iLumi = 0; iLumi < nConcurrentLumis; ++iLumi) {
454 bool expected =
false;
458 reportSvc->reportRandomStateFile(
fullName);
464 std::vector<RandomEngineState>
const& iStates) {
540 os <<
"\n\nRandomNumberGeneratorService dump\n\n";
542 os <<
" Contents of seedsAndNameMap (label moduleID engineType seeds)\n";
544 os <<
" " <<
entry.first <<
" " <<
entry.second.moduleID() <<
" " <<
entry.second.engineName();
545 for (
auto val :
entry.second.seeds()) {
550 os <<
" nStreams_ = " <<
nStreams_ <<
"\n";
556 os <<
" verbose_ = " <<
verbose_ <<
"\n";
560 os <<
"\n streamEngines_\n";
561 unsigned int iStream = 0;
563 os <<
" Stream " << iStream <<
"\n";
564 for (
auto const&
i :
k) {
565 os <<
" " <<
i.label();
566 for (
auto const&
j :
i.seeds()) {
569 os <<
" " <<
i.engine()->name();
570 if (
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
571 os <<
" " <<
i.engine()->getSeed();
572 }
else if (
i.engine()->name() ==
std::string(
"MixMaxRng")) {
573 os <<
" " <<
i.engine()->getSeed();
575 os <<
" engine does not know seeds";
581 os <<
"\n lumiEngines_\n";
582 unsigned int iLumi = 0;
584 os <<
" lumiIndex " << iLumi <<
"\n";
585 for (
auto const&
i :
k) {
586 os <<
" " <<
i.label();
587 for (
auto const&
j :
i.seeds()) {
590 os <<
" " <<
i.engine()->name();
591 if (
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
592 os <<
" " <<
i.engine()->getSeed();
593 }
else if (
i.engine()->name() ==
std::string(
"MixMaxRng")) {
594 os <<
" " <<
i.engine()->getSeed();
596 os <<
" engine does not know seeds";
609 std::vector<ModuleIDToEngine>::iterator iter =
611 if (iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
613 iter->setEngineState(labelAndEngine->
engine()->put());
623 std::vector<ModuleIDToEngine>::iterator iter =
625 if (iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
627 if (iter->engineState() != labelAndEngine->
engine()->put()) {
629 <<
"It is illegal to generate random numbers during beginStream, endStream,\n" 630 "beginRun, endRun, beginLumi, endLumi because that makes it very difficult\n" 631 "to replay the processing of individual events. Random numbers were\n" 632 "generated during one of these methods for the module with class name\n\"" 635 "and module label \"" 647 <<
"In the configuration for the RandomNumberGeneratorService the\n" 648 <<
"restoreStateTag contains the current process which is illegal.\n" 649 <<
"The process name in the replay process should have been changed\n" 650 <<
"to be different than the original process name and the restoreStateTag\n" 651 <<
"should contain either the original process name or an empty process name.\n";
660 <<
"The RandomNumberGeneratorService is trying to restore\n" 661 <<
"the state of the random engines by reading a product from\n" 663 <<
"It could not find the product.\n" 664 <<
"Either the product in the LuminosityBlock was dropped or\n" 665 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
678 <<
"The RandomNumberGeneratorService is trying to restore\n" 679 <<
"the state of the random engines by reading a product from\n" 681 <<
"It could not find the product.\n" 682 <<
"Either the product in the Event was dropped or\n" 683 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
690 std::vector<RandomEngineState>&
cache) {
691 cache.resize(engines.size());
692 std::vector<RandomEngineState>::iterator
state =
cache.begin();
694 for (std::vector<LabelAndEngine>::const_iterator iter = engines.begin(); iter != engines.end(); ++iter, ++
state) {
697 state->setSeed(iter->seeds());
699 std::vector<unsigned long> stateL = iter->engine()->put();
700 state->clearStateVector();
701 state->reserveStateVector(stateL.size());
702 for (
auto element : stateL) {
703 state->push_back_stateVector(static_cast<std::uint32_t>(element));
709 std::vector<LabelAndEngine>& engines) {
710 std::vector<LabelAndEngine>::iterator labelAndEngine = engines.begin();
711 for (
auto const& cachedState :
cache) {
712 std::string const& engineLabel = cachedState.getLabel();
714 std::vector<std::uint32_t>
const& engineState = cachedState.getState();
715 std::vector<unsigned long> engineStateL;
716 engineStateL.reserve(engineState.size());
717 for (
auto const&
value : engineState) {
718 engineStateL.push_back(static_cast<unsigned long>(
value));
721 std::vector<std::uint32_t>
const& engineSeeds = cachedState.getSeed();
722 std::vector<long> engineSeedsL;
723 engineSeedsL.reserve(engineSeeds.size());
724 for (
auto const&
val : engineSeeds) {
725 long seedL =
static_cast<long>(
val);
726 engineSeedsL.push_back(seedL);
735 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
739 assert(labelAndEngine != engines.end() && engineLabel == labelAndEngine->label());
740 std::shared_ptr<CLHEP::HepRandomEngine>
const& engine = labelAndEngine->engine();
744 if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
748 engine->setSeed(engineSeedsL[0], 0);
749 engine->get(engineStateL);
751 labelAndEngine->setSeed(engineSeeds[0], 0);
752 }
else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
756 engine->get(engineStateL);
758 labelAndEngine->setSeed(engineSeeds[0], 0);
759 labelAndEngine->setSeed(engineSeeds[1], 1);
760 }
else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::MixMaxRng>()) {
764 engine->setSeed(engineSeedsL[0], 0);
765 engine->get(engineStateL);
767 labelAndEngine->setSeed(engineSeeds[0], 0);
768 }
else if (engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
772 engine->setSeed(engineSeedsL[0], 0);
773 engine->get(engineStateL);
775 labelAndEngine->setSeed(engineSeeds[0], 0);
780 <<
"The RandomNumberGeneratorService is trying to restore the state\n" 781 "of the random engines. The state in the event indicates an engine\n" 782 "of an unknown type. This should not be possible unless you are\n" 783 "running with an old code release on a new file that was created\n" 784 "with a newer release which had new engine types added. In this case\n" 785 "the only solution is to use a newer release. In any other case, notify\n" 786 "the EDM developers because this should not be possible\n";
795 if (typeFromConfig != typeFromEvent) {
797 <<
"The RandomNumberGeneratorService is trying to restore\n" 798 <<
"the state of the random engine for the module \"" << engineLabel <<
"\". An\n" 799 <<
"error was detected because the type of the engine in the\n" 800 <<
"input file and the configuration file do not match.\n" 801 <<
"In the configuration file the type is \"" << typeFromConfig <<
"\".\nIn the input file the type is \"" 802 << typeFromEvent <<
"\". If\n" 803 <<
"you are not generating any random numbers in this module, then\n" 804 <<
"remove the line in the configuration file that gives it\n" 805 <<
"a seed and the error will go away. Otherwise, you must give\n" 806 <<
"this module the same engine type in the configuration file or\n" 807 <<
"stop trying to restore the random engine state.\n";
817 std::stringstream
file;
827 <<
"Unable to open the file \"" <<
file.str() <<
"\" to save the state of the random engines.\n";
831 outFile.seekp(0, std::ios_base::beg);
832 outFile <<
"<RandomEngineStates>\n";
842 outFile <<
"</RandomEngineStates>\n";
848 std::vector<std::uint32_t>
const& seedVector =
state.getSeed();
851 std::vector<std::uint32_t>
const& stateVector =
state.getState();
854 outFile <<
"<ModuleLabel>\n" <<
state.getLabel() <<
"\n</ModuleLabel>\n";
856 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n";
859 outFile <<
"</InitialSeeds>\n";
860 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
870 size_t numItems =
v.size();
871 for (
size_t i = 0;
i < numItems; ++
i) {
872 if (
i != 0 &&
i % 10 == 0)
887 std::vector<RandomEngineState>&
cache) {
893 std::vector<RandomEngineState>&
cache) {
899 std::vector<RandomEngineState>&
cache,
905 <<
"Unable to open the file \"" <<
fileName <<
"\" to restore the random engine states.\n";
912 <<
"Attempting to read file with random number engine states.\n" 913 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 914 <<
"Cannot read the file header word.\n";
916 bool saveToCache =
false;
922 std::vector<RandomEngineState>&
cache,
929 std::vector<std::uint32_t> seedVector;
931 std::vector<std::uint32_t> stateVector;
940 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 941 <<
"Cannot read next field and did not hit the end yet.\n";
945 if (leading ==
std::string(
"</RandomEngineStates>"))
956 saveToCache = (leading == whichStates);
965 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 966 <<
"Cannot read a module label when restoring random engine states.\n";
969 is >> leading >> seedVectorSize >> trailing;
972 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 973 <<
"Cannot read seed vector length when restoring random engine states.\n";
977 if (!is.good() || leading !=
std::string(
"<InitialSeeds>")) {
979 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 980 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
985 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 986 <<
"The number of seeds exceeds 64K.\n";
992 if (!is.good() || trailing !=
std::string(
"</InitialSeeds>")) {
994 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 995 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
998 is >> leading >> stateVectorSize >> trailing;
999 if (!is.good() || leading !=
std::string(
"<FullStateLength>") || trailing !=
std::string(
"</FullStateLength>")) {
1001 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1002 <<
"Cannot read state vector length when restoring random engine states.\n";
1006 if (!is.good() || leading !=
std::string(
"<FullState>")) {
1008 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1009 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1014 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1015 <<
"The number of states exceeds 64K.\n";
1018 readVector(is, stateVectorSize, stateVector);
1021 if (!is.good() || trailing !=
std::string(
"</FullState>")) {
1023 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1024 <<
"Cannot read end of FullState when restoring random engine states.\n";
1030 std::vector<RandomEngineState>::iterator
state =
1034 if (seedVector.size() !=
state->getSeed().size() || stateVector.size() !=
state->getState().size()) {
1036 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1037 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1039 state->setSeed(seedVector);
1040 state->setState(stateVector);
1048 v.reserve(numItems);
1050 for (
unsigned i = 0;
i < numItems; ++
i) {
1054 <<
"File \"" <<
restoreFileName_ <<
"\" is ill-structured or otherwise corrupted.\n" 1055 <<
"Cannot read vector when restoring random engine states.\n";
1062 unsigned int seedOffset,
1063 unsigned int eventSeedOffset,
1064 std::vector<ModuleIDToEngine>& moduleIDVector) {
1071 unsigned int moduleID =
i.second.moduleID();
1077 if (
name ==
"RanecuEngine") {
1078 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::RanecuEngine>();
1084 long int seedL =
static_cast<long int>(
seeds[0]);
1086 if (
name ==
"HepJamesRandom") {
1087 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::HepJamesRandom>(seedL);
1089 if (seedOffset != 0 || eventSeedOffset != 0) {
1092 }
else if (
name ==
"MixMaxRng") {
1093 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::MixMaxRng>(seedL);
1095 if (seedOffset != 0 || eventSeedOffset != 0) {
1107 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1110 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<TRandomAdaptor>(seedL);
1112 if (seedOffset != 0 || eventSeedOffset != 0) {
1117 moduleIDVector.emplace_back(&engines.back(), moduleID);
1120 std::sort(moduleIDVector.begin(), moduleIDVector.end());
1126 std::uint32_t offset1,
1127 std::uint32_t offset2) {
1134 std::uint32_t seed0 = (
seeds[0] + offset1) %
mod;
1135 seed0 = (seed0 + offset2) %
mod;
1136 labelAndEngine.
setSeed(seed0, 0);
1139 seedL[0] =
static_cast<long int>(seed0);
1140 seedL[1] =
static_cast<long int>(
seeds[1]);
1141 labelAndEngine.
engine()->setSeeds(seedL, 0);
1150 std::uint32_t seed0 = (
seeds[0] + offset1) %
mod;
1151 seed0 = (seed0 + offset2) %
mod;
1152 labelAndEngine.
setSeed(seed0, 0);
1154 long int seedL =
static_cast<long int>(seed0);
1155 labelAndEngine.
engine()->setSeed(seedL, 0);
1162 std::uint32_t seed0 =
seeds[0];
1163 if ((max32 - seed0) >= offset1) {
1166 seed0 = offset1 - (max32 - seed0) - 1
U;
1168 if ((max32 - seed0) >= offset2) {
1171 seed0 = offset2 - (max32 - seed0) - 1
U;
1173 labelAndEngine.
setSeed(seed0, 0);
1175 long seedL =
static_cast<long>(seed0);
1184 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1185 assert(seed0 == seedu32);
1187 labelAndEngine.
engine()->setSeed(seedL, 0);
void writeStates(std::vector< RandomEngineState > const &v, std::ofstream &outFile)
void preModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
ModuleDescription const * moduleDescription() const
void readVector(std::istream &is, unsigned numItems, std::vector< std::uint32_t > &v)
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
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)
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
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)