40 #include "CLHEP/Random/engineIDulong.h"
41 #include "CLHEP/Random/JamesRandom.h"
42 #include "CLHEP/Random/RanecuEngine.h"
66 saveFileName_(pset.getUntrackedParameter<std::
string>(
"saveFileName")),
67 saveFileNameRecorded_(
false),
68 restoreFileName_(pset.getUntrackedParameter<std::
string>(
"restoreFileName")),
69 enableChecking_(pset.getUntrackedParameter<bool>(
"enableChecking")),
71 eventSeedOffset_(pset.getUntrackedParameter<unsigned>(
"eventSeedOffset")),
72 verbose_(pset.getUntrackedParameter<bool>(
"verbose")) {
74 if(pset.
exists(
"restoreStateTag")) {
86 <<
"In the configuration for the RandomNumberGeneratorService both\n"
87 <<
"restoreFileName and restoreStateLabel were set to nonempty values\n"
88 <<
"which is illegal. It is impossible to restore the random engine\n"
89 <<
"states two different ways in the same process.\n";
96 <<
"The saveFileName parameter must be a simple file name with no path\n"
97 <<
"specification. In the configuration, it was given the value \""
101 std::uint32_t initialSeed;
106 for(
auto const&
label : pSets) {
111 bool initialSeedExists = modulePSet.
exists(
"initialSeed");
112 bool initialSeedSetExists = modulePSet.
exists(
"initialSeedSet");
114 if(initialSeedExists && initialSeedSetExists) {
116 <<
"For the module with the label \"" <<
label <<
"\",\n"
117 <<
"both the parameters \"initialSeed\" and \"initialSeedSet\"\n"
118 <<
"have been set in the configuration. You must set one or\n"
119 <<
"the other. It is illegal to set both.\n";
120 }
else if(!initialSeedExists && !initialSeedSetExists) {
122 <<
"For the module with the label \"" <<
label <<
"\",\n"
123 <<
"neither the parameter \"initialSeed\" nor \"initialSeedSet\"\n"
124 <<
"has been set in the configuration. You must set one or\n"
126 }
else if(initialSeedExists) {
128 initialSeedSet.clear();
129 initialSeedSet.push_back(initialSeed);
130 }
else if(initialSeedSetExists) {
137 if(initialSeedSet.size() != 2U) {
139 <<
"Random engines of type \"RanecuEngine\" require 2 seeds\n"
140 <<
"be specified with the parameter named \"initialSeedSet\".\n"
141 <<
"Either \"initialSeedSet\" was not in the configuration\n"
142 <<
"or its size was not 2 for the module with label \"" <<
label <<
"\".\n" ;
147 <<
"The RanecuEngine seeds should be in the range 0 to 2147483647.\n"
148 <<
"The seeds passed to the RandomNumberGenerationService from the\n"
149 "configuration file were " << initialSeedSet[0] <<
" and " << initialSeedSet[1]
150 <<
"\nThis was for the module with label \"" <<
label <<
"\".\n";
155 if(initialSeedSet.size() != 1U) {
157 <<
"Random engines of type \"HepJamesRandom\" and \"TRandom3\n"
158 <<
"require exactly 1 seed be specified in the configuration.\n"
159 <<
"There were " << initialSeedSet.size() <<
" seeds set for the\n"
160 <<
"module with label \"" <<
label <<
"\".\n" ;
162 if(engineName ==
"HepJamesRandom") {
165 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to 900000000.\n"
166 <<
"The seed passed to the RandomNumberGenerationService from the\n"
167 "configuration file was " << initialSeedSet[0] <<
". This was for \n"
168 <<
"the module with label " <<
label <<
".\n";
170 }
else if(engineName !=
"TRandom3") {
172 <<
"The random engine name, \"" << engineName
173 <<
"\", does not correspond to a supported engine.\n"
174 <<
"This engine was configured for the module with label \"" <<
label <<
"\"";
217 CLHEP::HepRandomEngine&
223 <<
"RandomNumberGeneratorService::getEngine\n"
224 "Requested a random number engine from the RandomNumberGeneratorService\n"
225 "when no module was active. ModuleCallingContext is null\n";
231 std::vector<ModuleIDToEngine>::const_iterator
iter = std::lower_bound(moduleIDVector.begin(),
232 moduleIDVector.end(),
234 if(iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
236 <<
"The module with label \""
238 <<
"\" requested a random number engine from the \n"
239 "RandomNumberGeneratorService, but that module was not configured\n"
240 "for random numbers. An engine is created only if a seed(s) is provided\n"
241 "in the configuration file. Please add the following PSet to the\n"
242 "configuration file for the RandomNumberGeneratorService:\n\n"
244 " initialSeed = cms.untracked.uint32(your_seed),\n"
245 " engineName = cms.untracked.string('TRandom3')\n"
247 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
248 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
251 return *iter->labelAndEngine()->engine();
254 CLHEP::HepRandomEngine&
260 <<
"RandomNumberGeneratorService::getEngine\n"
261 "Requested a random number engine from the RandomNumberGeneratorService\n"
262 "when no module was active. ModuleCallingContext is null\n";
268 std::vector<ModuleIDToEngine>::const_iterator
iter = std::lower_bound(moduleIDVector.begin(),
269 moduleIDVector.end(),
271 if(iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
273 <<
"The module with label \""
275 <<
"\" requested a random number engine from the \n"
276 "RandomNumberGeneratorService, but that module was not configured\n"
277 "for random numbers. An engine is created only if a seed(s) is provided\n"
278 "in the configuration file. Please add the following PSet to the\n"
279 "configuration file for the RandomNumberGeneratorService:\n\n"
281 " initialSeed = cms.untracked.uint32(your_seed),\n"
282 " engineName = cms.untracked.string('TRandom3')\n"
284 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
285 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
288 return *iter->labelAndEngine()->engine();
307 <<
"RandomNumberGeneratorService::getEngine()\n"
308 "Requested a random number engine from the RandomNumberGeneratorService\n"
309 "when no module was active. ModuleCallingContext is null\n";
318 <<
"The module with label \""
320 <<
"\" requested a random number seed from the \n"
321 "RandomNumberGeneratorService, but that module was not configured\n"
322 "for random numbers. An engine is created only if a seed(s) is provided\n"
323 "in the configuration file. Please add the following PSet to the\n"
324 "configuration file for the RandomNumberGeneratorService:\n\n"
325 " " << label <<
" = cms.PSet(\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];
353 val.addOptionalUntracked<std::vector<std::uint32_t> >(
"initialSeedSet");
354 val.addOptionalUntracked<
std::string>(
"engineName");
357 wnode.setComment(
"The name of each ParameterSet will be the associated module label.");
360 descriptions.
add(
"RandomNumberGeneratorService", desc);
367 iter->second.setModuleID(description.
id());
408 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n"
409 <<
"to run replay using a text file to input the random engine states and\n"
410 <<
"the number of streams is greater than 1. Either set the\n"
411 <<
"parameter named \"restoreFileName\" in the RandomNumberGeneratorService\n"
412 <<
"to the empty string or set the parameter \"numberOfStreams\" in the top\n"
413 <<
"level options parameter set to 1. (Probably these are the default values\n"
414 <<
"and just not setting the parameters will also work)\n";
426 for(
unsigned int iStream = 0; iStream <
nStreams_; ++iStream) {
427 unsigned int seedOffset = iStream;
430 outFiles_[iStream].reset(
new std::ofstream);
433 for(
unsigned int iLumi = 0; iLumi < nConcurrentLumis; ++iLumi) {
460 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n"
461 <<
"to run replay using a text file to input the random engine states and\n"
462 <<
"the process is configured to fork multiple processes. No forking is\n"
463 <<
"is allowed with this type of replay\n";
468 for(
auto& labelAndEngine : engines) {
469 std::map<std::string, SeedsAndName>::const_iterator seedsAndName =
seedsAndNameMap_.find(labelAndEngine.label());
472 seedsAndName->second.engineName(),
473 seedsAndName->second.seeds(),
478 if (kMaxChildren != 0) {
481 for(
auto& labelAndEngine : engines) {
482 std::map<std::string, SeedsAndName>::const_iterator seedsAndName =
seedsAndNameMap_.find(labelAndEngine.label());
485 seedsAndName->second.engineName(),
486 seedsAndName->second.seeds(),
495 std::ostringstream
suffix;
496 suffix <<
"_" << childIndex;
537 bool expected =
false;
541 reportSvc->reportRandomStateFile(fullName);
606 std::vector<RandomEngineState>
const&
611 std::vector<RandomEngineState>
const&
619 os <<
"\n\nRandomNumberGeneratorService dump\n\n";
621 os <<
" Contents of seedsAndNameMap (label moduleID engineType seeds)\n";
623 os <<
" " << entry.first
624 <<
" " << entry.second.moduleID()
625 <<
" " << entry.second.engineName();
626 for(
auto val : entry.second.seeds()) {
631 os <<
" nStreams_ = " <<
nStreams_ <<
"\n";
638 os <<
" verbose_ = " <<
verbose_ <<
"\n";
642 os <<
"\n streamEngines_\n";
643 unsigned int iStream = 0;
645 os <<
" Stream " << iStream <<
"\n";
646 for(
auto const&
i :
k) {
647 os <<
" " <<
i.label();
648 for(
auto const&
j :
i.seeds()) {
651 os <<
" " <<
i.engine()->name();
652 if(
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
653 os <<
" " <<
i.engine()->getSeed();
655 os <<
" engine does not know seeds";
661 os <<
"\n lumiEngines_\n";
662 unsigned int iLumi = 0;
664 os <<
" lumiIndex " << iLumi <<
"\n";
665 for(
auto const&
i :
k) {
666 os <<
" " <<
i.label();
667 for(
auto const&
j :
i.seeds()) {
670 os <<
" " <<
i.engine()->name();
671 if(
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
672 os <<
" " <<
i.engine()->getSeed();
674 os <<
" engine does not know seeds";
688 std::vector<ModuleIDToEngine>::iterator
iter = std::lower_bound(moduleIDVector.begin(),
689 moduleIDVector.end(),
691 if(iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
693 iter->setEngineState(labelAndEngine->
engine()->put());
704 std::vector<ModuleIDToEngine>::const_iterator
iter = std::lower_bound(moduleIDVector.begin(),
705 moduleIDVector.end(),
707 if(iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
709 if(iter->engineState() != labelAndEngine->
engine()->put()) {
711 <<
"It is illegal to generate random numbers during beginStream, endStream,\n"
712 "beginRun, endRun, beginLumi, endLumi because that makes it very difficult\n"
713 "to replay the processing of individual events. Random numbers were\n"
714 "generated during one of these methods for the module with class name\n\""
729 <<
"In the configuration for the RandomNumberGeneratorService the\n"
730 <<
"restoreStateTag contains the current process which is illegal.\n"
731 <<
"The process name in the replay process should have been changed\n"
732 <<
"to be different than the original process name and the restoreStateTag\n"
733 <<
"should contain either the original process name or an empty process name.\n";
742 <<
"The RandomNumberGeneratorService is trying to restore\n"
743 <<
"the state of the random engines by reading a product from\n"
745 <<
"It could not find the product.\n"
746 <<
"Either the product in the LuminosityBlock was dropped or\n"
747 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
762 <<
"The RandomNumberGeneratorService is trying to restore\n"
763 <<
"the state of the random engines by reading a product from\n"
765 <<
"It could not find the product.\n"
766 <<
"Either the product in the Event was dropped or\n"
767 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
775 cache.resize(engines.size());
776 std::vector<RandomEngineState>::iterator state = cache.begin();
778 for(std::vector<LabelAndEngine>::const_iterator
iter = engines.begin();
779 iter != engines.end();
783 state->setLabel(label);
784 state->setSeed(
iter->seeds());
786 std::vector<unsigned long> stateL =
iter->engine()->put();
787 state->clearStateVector();
788 state->reserveStateVector(stateL.size());
789 for(
auto element : stateL) {
790 state->push_back_stateVector(static_cast<std::uint32_t>(element));
797 std::vector<LabelAndEngine>& engines) {
798 std::vector<LabelAndEngine>::iterator labelAndEngine = engines.begin();
799 for(
auto const& cachedState : cache) {
801 std::string const& engineLabel = cachedState.getLabel();
803 std::vector<std::uint32_t>
const& engineState = cachedState.getState();
804 std::vector<unsigned long> engineStateL;
805 engineStateL.reserve(engineState.size());
806 for(
auto const&
value : engineState) {
807 engineStateL.push_back(static_cast<unsigned long>(
value));
810 std::vector<std::uint32_t>
const& engineSeeds = cachedState.getSeed();
811 std::vector<long> engineSeedsL;
812 engineSeedsL.reserve(engineSeeds.size());
813 for(
auto const& val : engineSeeds) {
814 long seedL =
static_cast<long>(val);
815 engineSeedsL.push_back(seedL);
824 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
825 assert(val == seedu32);
828 assert(labelAndEngine != engines.end() && engineLabel == labelAndEngine->label());
829 std::shared_ptr<CLHEP::HepRandomEngine>
const& engine = labelAndEngine->engine();
833 if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
838 engine->setSeed(engineSeedsL[0], 0);
839 engine->get(engineStateL);
841 labelAndEngine->setSeed(engineSeeds[0], 0);
842 }
else if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
847 engine->get(engineStateL);
849 labelAndEngine->setSeed(engineSeeds[0], 0);
850 labelAndEngine->setSeed(engineSeeds[1], 1);
851 }
else if(engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
856 engine->setSeed(engineSeedsL[0], 0);
857 engine->get(engineStateL);
859 labelAndEngine->setSeed(engineSeeds[0], 0);
864 <<
"The RandomNumberGeneratorService is trying to restore the state\n"
865 "of the random engines. The state in the event indicates an engine\n"
866 "of an unknown type. This should not be possible unless you are\n"
867 "running with an old code release on a new file that was created\n"
868 "with a newer release which had new engine types added. In this case\n"
869 "the only solution is to use a newer release. In any other case, notify\n"
870 "the EDM developers because this should not be possible\n";
880 if(typeFromConfig != typeFromEvent) {
882 <<
"The RandomNumberGeneratorService is trying to restore\n"
883 <<
"the state of the random engine for the module \""
884 << engineLabel <<
"\". An\n"
885 <<
"error was detected because the type of the engine in the\n"
886 <<
"input file and the configuration file do not match.\n"
887 <<
"In the configuration file the type is \"" << typeFromConfig
888 <<
"\".\nIn the input file the type is \"" << typeFromEvent <<
"\". If\n"
889 <<
"you are not generating any random numbers in this module, then\n"
890 <<
"remove the line in the configuration file that gives it\n"
891 <<
"a seed and the error will go away. Otherwise, you must give\n"
892 <<
"this module the same engine type in the configuration file or\n"
893 <<
"stop trying to restore the random engine state.\n";
904 if(!outFile.is_open()) {
905 std::stringstream
file;
908 file <<
"_" << streamID.
value();
915 <<
"Unable to open the file \""
916 << file.str() <<
"\" to save the state of the random engines.\n";
920 outFile.seekp(0, std::ios_base::beg);
921 outFile <<
"<RandomEngineStates>\n";
923 outFile <<
"<Event>\n";
925 outFile <<
"</Event>\n";
927 outFile <<
"<Lumi>\n";
929 outFile <<
"</Lumi>\n";
931 outFile <<
"</RandomEngineStates>\n";
938 for(std::vector<RandomEngineState>::const_iterator
iter = v.begin(),
942 std::vector<std::uint32_t>
const& seedVector =
iter->getSeed();
945 std::vector<std::uint32_t>
const& stateVector =
iter->getState();
948 outFile <<
"<ModuleLabel>\n" <<
iter->getLabel() <<
"\n</ModuleLabel>\n";
950 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n" ;
951 outFile <<
"<InitialSeeds>\n";
953 outFile <<
"</InitialSeeds>\n";
954 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
955 outFile <<
"<FullState>\n";
957 outFile <<
"</FullState>\n";
964 if(v.empty())
return;
965 size_t numItems = v.size();
966 for(
size_t i = 0;
i < numItems; ++
i) {
967 if(
i != 0 &&
i % 10 == 0) outFile <<
"\n";
968 outFile << std::setw(13) << v[
i];
982 std::vector<RandomEngineState>& cache) {
989 std::vector<RandomEngineState>& cache) {
997 std::vector<RandomEngineState>& cache,
999 std::ifstream inFile;
1003 <<
"Unable to open the file \""
1004 << fileName <<
"\" to restore the random engine states.\n";
1009 if(!inFile.good() || text !=
std::string(
"<RandomEngineStates>")) {
1011 <<
"Attempting to read file with random number engine states.\n"
1013 <<
"\" is ill-structured or otherwise corrupted.\n"
1014 <<
"Cannot read the file header word.\n";
1016 bool saveToCache =
false;
1021 std::vector<RandomEngineState>& cache,
1023 bool& saveToCache) {
1028 std::vector<std::uint32_t> seedVector;
1030 std::vector<std::uint32_t> stateVector;
1040 <<
"\" is ill-structured or otherwise corrupted.\n"
1041 <<
"Cannot read next field and did not hit the end yet.\n";
1045 if(leading ==
std::string(
"</RandomEngineStates>"))
return false;
1050 saveToCache =
false;
1057 saveToCache = (leading == whichStates);
1063 is >> moduleLabel >> trailing;
1069 <<
"\" is ill-structured or otherwise corrupted.\n"
1070 <<
"Cannot read a module label when restoring random engine states.\n";
1073 is >> leading >> seedVectorSize >> trailing;
1079 <<
"\" is ill-structured or otherwise corrupted.\n"
1080 <<
"Cannot read seed vector length when restoring random engine states.\n";
1088 <<
"\" is ill-structured or otherwise corrupted.\n"
1089 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1095 <<
"\" is ill-structured or otherwise corrupted.\n"
1096 <<
"The number of seeds exceeds 64K.\n";
1106 <<
"\" is ill-structured or otherwise corrupted.\n"
1107 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
1110 is >> leading >> stateVectorSize >> trailing;
1116 <<
"\" is ill-structured or otherwise corrupted.\n"
1117 <<
"Cannot read state vector length when restoring random engine states.\n";
1125 <<
"\" is ill-structured or otherwise corrupted.\n"
1126 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1132 <<
"\" is ill-structured or otherwise corrupted.\n"
1133 <<
"The number of states exceeds 64K.\n";
1136 readVector(is, stateVectorSize, stateVector);
1143 <<
"\" is ill-structured or otherwise corrupted.\n"
1144 <<
"Cannot read end of FullState when restoring random engine states.\n";
1149 randomEngineState.
setLabel(moduleLabel);
1150 std::vector<RandomEngineState>::iterator state =
1151 std::lower_bound(cache.begin(), cache.end(), randomEngineState);
1153 if(state != cache.end() && moduleLabel == state->getLabel()) {
1154 if(seedVector.size() != state->getSeed().size() ||
1155 stateVector.size() != state->getState().size()) {
1158 <<
"\" is ill-structured or otherwise corrupted.\n"
1159 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1161 state->setSeed(seedVector);
1162 state->setState(stateVector);
1171 v.reserve(numItems);
1173 for(
unsigned i = 0;
i < numItems; ++
i) {
1178 <<
"\" is ill-structured or otherwise corrupted.\n"
1179 <<
"Cannot read vector when restoring random engine states.\n";
1187 unsigned int seedOffset,
1188 unsigned int eventSeedOffset,
1189 std::vector<ModuleIDToEngine>& moduleIDVector) {
1196 unsigned int moduleID =
i.second.moduleID();
1200 VUint32 const& seeds =
i.second.seeds();
1202 if(name ==
"RanecuEngine") {
1203 std::shared_ptr<CLHEP::HepRandomEngine> engine(
new CLHEP::RanecuEngine());
1204 engines.emplace_back(label, seeds, engine);
1209 long int seedL =
static_cast<long int>(seeds[0]);
1211 if(name ==
"HepJamesRandom") {
1212 std::shared_ptr<CLHEP::HepRandomEngine> engine(
new CLHEP::HepJamesRandom(seedL));
1213 engines.emplace_back(label, seeds, engine);
1214 if(seedOffset != 0 || eventSeedOffset != 0) {
1226 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1227 assert(seeds[0] == seedu32);
1229 std::shared_ptr<CLHEP::HepRandomEngine> engine(
new TRandomAdaptor(seedL));
1230 engines.emplace_back(label, seeds, engine);
1231 if(seedOffset != 0 || eventSeedOffset != 0) {
1236 moduleIDVector.emplace_back(&engines.back(), moduleID);
1239 std::sort(moduleIDVector.begin(), moduleIDVector.end());
1246 std::uint32_t offset1,
1247 std::uint32_t offset2) {
1249 if(engineName ==
"RanecuEngine") {
1250 assert(seeds.size() == 2U);
1255 std::uint32_t seed0 = (seeds[0] + offset1) % mod;
1256 seed0 = (seed0 + offset2) % mod;
1257 labelAndEngine.
setSeed(seed0, 0);
1258 labelAndEngine.
setSeed(seeds[1], 1);
1260 seedL[0] =
static_cast<long int>(seed0);
1261 seedL[1] =
static_cast<long int>(seeds[1]);
1262 labelAndEngine.
engine()->setSeeds(seedL,0);
1264 assert(seeds.size() == 1U);
1266 if(engineName ==
"HepJamesRandom") {
1271 std::uint32_t seed0 = (seeds[0] + offset1) % mod;
1272 seed0 = (seed0 + offset2) % mod;
1273 labelAndEngine.
setSeed(seed0, 0);
1275 long int seedL =
static_cast<long int>(seed0);
1276 labelAndEngine.
engine()->setSeed(seedL, 0);
1278 assert(engineName ==
"TRandom3");
1283 std::uint32_t seed0 = seeds[0];
1284 if((max32 - seed0) >= offset1) {
1287 seed0 = offset1 - (max32 - seed0) - 1U;
1289 if((max32 - seed0) >= offset2) {
1292 seed0 = offset2 - (max32 - seed0) - 1U;
1294 labelAndEngine.
setSeed(seed0, 0);
1296 long seedL =
static_cast<long>(seed0);
1305 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1306 assert(seed0 == seedu32);
1308 labelAndEngine.
engine()->setSeed(seedL, 0);
void watchPostModuleConstruction(PostModuleConstruction::slot_type const &iSlot)
void writeStates(std::vector< RandomEngineState > const &v, std::ofstream &outFile)
T getUntrackedParameter(std::string const &, T const &) const
void preModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
void readVector(std::istream &is, unsigned numItems, std::vector< std::uint32_t > &v)
void watchPreallocate(Preallocate::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static const std::uint32_t maxSeedRanecu
LuminosityBlockIndex index() const
std::shared_ptr< CLHEP::HepRandomEngine > const & engine() const
void postModuleEndJob(ModuleDescription const &description)
void watchPostModuleEndStream(PostModuleEndStream::slot_type const &iSlot)
void readFromEvent(Event const &event)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
std::atomic< bool > saveFileNameRecorded_
std::string constructSaveFileName() const
static thread_local std::string moduleLabel_
void setLabel(const std::string &value)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static ModuleCallingContext const * getCurrentModuleOnThread()
std::string const & moduleName() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void preModuleEndStream(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPostModuleStreamEndLumi(PostModuleStreamEndLumi::slot_type const &iSlot)
void watchPostModuleStreamBeginRun(PostModuleStreamBeginRun::slot_type const &iSlot)
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)
std::vector< std::shared_ptr< std::ofstream > > outFiles_
void resetEngineSeeds(LabelAndEngine &labelAndEngine, std::string const &engineName, VUint32 const &seeds, std::uint32_t offset1, std::uint32_t offset2)
void preModuleBeginJob(ModuleDescription const &description)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
void readFromLuminosityBlock(LuminosityBlock const &lumi)
std::string const & moduleLabel() const
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)
std::string saveFileName_
void postModuleEndStream(StreamContext const &sc, ModuleCallingContext const &mcc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
unsigned int maxNumberOfStreams() const
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)
const T & max(const T &a, const T &b)
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)
ModuleDescription const * moduleDescription() const
static const std::uint32_t maxSeedTRandom3
virtual 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_
void watchPreModuleEndJob(PreModuleEndJob::slot_type const &iSlot)
unsigned int value() const
void readStatesFromFile(std::string const &fileName, std::vector< RandomEngineState > &cache, std::string const &whichStates)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void readEventStatesFromTextFile(std::string const &fileName, std::vector< RandomEngineState > &cache)
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
std::vector< std::vector< RandomEngineState > > lumiCache_
void postModuleBeginJob(ModuleDescription const &description)
static const std::vector< std::uint32_t >::size_type maxStates
void watchPostModuleStreamEndRun(PostModuleStreamEndRun::slot_type const &iSlot)
StreamID const & streamID() const
void preModuleStreamEndRun(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPreModuleStreamBeginLumi(PreModuleStreamBeginLumi::slot_type const &iSlot)
virtual std::uint32_t mySeed() const override
void preallocate(SystemBounds const &)
void watchPostModuleBeginStream(PostModuleBeginStream::slot_type const &iSlot)
std::vector< std::uint32_t > VUint32
unsigned int value() const
unsigned int maxNumberOfConcurrentLuminosityBlocks() const
void watchPostModuleStreamBeginLumi(PostModuleStreamBeginLumi::slot_type const &iSlot)
ParameterSet const & getParameterSet(std::string const &) const
void preModuleEndJob(ModuleDescription const &description)
void watchPreModuleStreamEndLumi(PreModuleStreamEndLumi::slot_type const &iSlot)
void checkEngineType(std::string const &typeFromConfig, std::string const &typeFromEvent, std::string const &engineLabel) const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &streamID) const override
Use this engine in event methods.
void watchPreModuleStreamBeginRun(PreModuleStreamBeginRun::slot_type const &iSlot)
edm::InputTag restoreStateBeginLumiTag_
void postForkReacquireResources(unsigned childIndex, unsigned kMaxChildren)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void watchPreModuleEndStream(PreModuleEndStream::slot_type const &iSlot)
void postModuleConstruction(ModuleDescription const &description)
void postModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
void watchPostForkReacquireResources(PostForkReacquireResources::slot_type const &iSlot)
virtual ~RandomNumberGeneratorService()
char data[epos_bytes_allocation]
virtual void postEventRead(Event const &event) override
virtual std::vector< RandomEngineState > const & getLumiCache(LuminosityBlockIndex const &) const override
These two are used by the RandomEngineStateProducer.
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 watchPostModuleBeginJob(PostModuleBeginJob::slot_type const &iSlot)
StreamID streamID() const
void readLumiStatesFromTextFile(std::string const &fileName, std::vector< RandomEngineState > &cache)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
void restoreFromCache(std::vector< RandomEngineState > const &cache, std::vector< LabelAndEngine > &engines)
volatile std::atomic< bool > shutdown_flag false
std::vector< std::vector< LabelAndEngine > > lumiEngines_
void postModuleBeginStream(StreamContext const &sc, ModuleCallingContext const &mcc)
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
virtual void preBeginLumi(LuminosityBlock const &lumi) override
void watchPostModuleEndJob(PostModuleEndJob::slot_type const &iSlot)
virtual std::vector< RandomEngineState > const & getEventCache(StreamID const &) const override
void postModuleStreamBeginLumi(StreamContext const &sc, ModuleCallingContext const &mcc)