41 #include "CLHEP/Random/engineIDulong.h"
42 #include "CLHEP/Random/JamesRandom.h"
43 #include "CLHEP/Random/RanecuEngine.h"
63 saveFileName_(pset.getUntrackedParameter<std::
string>(
"saveFileName")),
64 saveFileNameRecorded_(
false),
65 restoreFileName_(pset.getUntrackedParameter<std::
string>(
"restoreFileName")),
66 enableChecking_(pset.getUntrackedParameter<bool>(
"enableChecking")),
68 eventSeedOffset_(pset.getUntrackedParameter<unsigned>(
"eventSeedOffset")),
69 verbose_(pset.getUntrackedParameter<bool>(
"verbose")) {
71 if(pset.
exists(
"restoreStateTag")) {
83 <<
"In the configuration for the RandomNumberGeneratorService both\n"
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 \""
103 for(
auto const&
label : pSets) {
108 bool initialSeedExists = modulePSet.
exists(
"initialSeed");
109 bool initialSeedSetExists = modulePSet.
exists(
"initialSeedSet");
111 if(initialSeedExists && initialSeedSetExists) {
113 <<
"For the module with the label \"" <<
label <<
"\",\n"
114 <<
"both the parameters \"initialSeed\" and \"initialSeedSet\"\n"
115 <<
"have been set in the configuration. You must set one or\n"
116 <<
"the other. It is illegal to set both.\n";
117 }
else if(!initialSeedExists && !initialSeedSetExists) {
119 <<
"For the module with the label \"" <<
label <<
"\",\n"
120 <<
"neither the parameter \"initialSeed\" nor \"initialSeedSet\"\n"
121 <<
"has been set in the configuration. You must set one or\n"
123 }
else if(initialSeedExists) {
125 initialSeedSet.clear();
126 initialSeedSet.push_back(initialSeed);
127 }
else if(initialSeedSetExists) {
134 if(initialSeedSet.size() != 2U) {
136 <<
"Random engines of type \"RanecuEngine\" require 2 seeds\n"
137 <<
"be specified with the parameter named \"initialSeedSet\".\n"
138 <<
"Either \"initialSeedSet\" was not in the configuration\n"
139 <<
"or its size was not 2 for the module with label \"" <<
label <<
"\".\n" ;
144 <<
"The RanecuEngine seeds should be in the range 0 to 2147483647.\n"
145 <<
"The seeds passed to the RandomNumberGenerationService from the\n"
146 "configuration file were " << initialSeedSet[0] <<
" and " << initialSeedSet[1]
147 <<
"\nThis was for the module with label \"" <<
label <<
"\".\n";
152 if(initialSeedSet.size() != 1U) {
154 <<
"Random engines of type \"HepJamesRandom\" and \"TRandom3\n"
155 <<
"require exactly 1 seed be specified in the configuration.\n"
156 <<
"There were " << initialSeedSet.size() <<
" seeds set for the\n"
157 <<
"module with label \"" <<
label <<
"\".\n" ;
159 if(engineName ==
"HepJamesRandom") {
162 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to 900000000.\n"
163 <<
"The seed passed to the RandomNumberGenerationService from the\n"
164 "configuration file was " << initialSeedSet[0] <<
". This was for \n"
165 <<
"the module with label " <<
label <<
".\n";
167 }
else if(engineName !=
"TRandom3") {
169 <<
"The random engine name, \"" << engineName
170 <<
"\", does not correspond to a supported engine.\n"
171 <<
"This engine was configured for the module with label \"" <<
label <<
"\"";
213 CLHEP::HepRandomEngine&
219 <<
"RandomNumberGeneratorService::getEngine\n"
220 "Requested a random number engine from the RandomNumberGeneratorService\n"
221 "when no module was active. ModuleCallingContext is null\n";
227 std::vector<ModuleIDToEngine>::iterator iter = std::lower_bound(moduleIDVector.begin(),
228 moduleIDVector.end(),
230 if(iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
232 <<
"The module with label \""
234 <<
"\" requested a random number engine from the \n"
235 "RandomNumberGeneratorService, but that module was not configured\n"
236 "for random numbers. An engine is created only if a seed(s) is provided\n"
237 "in the configuration file. Please add the following PSet to the\n"
238 "configuration file for the RandomNumberGeneratorService:\n\n"
240 " initialSeed = cms.untracked.uint32(your_seed),\n"
241 " engineName = cms.untracked.string('TRandom3')\n"
243 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
244 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
247 return *iter->labelAndEngine()->engine();
250 CLHEP::HepRandomEngine&
256 <<
"RandomNumberGeneratorService::getEngine\n"
257 "Requested a random number engine from the RandomNumberGeneratorService\n"
258 "when no module was active. ModuleCallingContext is null\n";
264 std::vector<ModuleIDToEngine>::iterator iter = std::lower_bound(moduleIDVector.begin(),
265 moduleIDVector.end(),
267 if(iter == moduleIDVector.end() || iter->moduleID() != moduleID) {
269 <<
"The module with label \""
271 <<
"\" requested a random number engine from the \n"
272 "RandomNumberGeneratorService, but that module was not configured\n"
273 "for random numbers. An engine is created only if a seed(s) is provided\n"
274 "in the configuration file. Please add the following PSet to the\n"
275 "configuration file for the RandomNumberGeneratorService:\n\n"
277 " initialSeed = cms.untracked.uint32(your_seed),\n"
278 " engineName = cms.untracked.string('TRandom3')\n"
280 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
281 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
284 return *iter->labelAndEngine()->engine();
299 <<
"RandomNumberGeneratorService::getEngine()\n"
300 "Requested a random number engine from the RandomNumberGeneratorService\n"
301 "from an unallowed transition. ModuleCallingContext is null\n";
306 std::map<std::string, SeedsAndName>::const_iterator iter =
seedsAndNameMap_.find(label);
309 <<
"The module with label \""
311 <<
"\" requested a random number seed from the \n"
312 "RandomNumberGeneratorService, but that module was not configured\n"
313 "for random numbers. An engine is created only if a seed(s) is provided\n"
314 "in the configuration file. Please add the following PSet to the\n"
315 "configuration file for the RandomNumberGeneratorService:\n\n"
316 " " << label <<
" = cms.PSet(\n"
317 " initialSeed = cms.untracked.uint32(your_seed),\n"
318 " engineName = cms.untracked.string('TRandom3')\n"
320 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
321 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
323 return iter->second.seeds()[0];
343 val.addOptionalUntracked<std::uint32_t>(
"initialSeed");
344 val.addOptionalUntracked<std::vector<std::uint32_t> >(
"initialSeedSet");
345 val.addOptionalUntracked<
std::string>(
"engineName");
348 wnode.setComment(
"The name of each ParameterSet will be the associated module label.");
351 descriptions.
add(
"RandomNumberGeneratorService", desc);
358 iter->second.setModuleID(description.
id());
369 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n"
370 <<
"to run replay using a text file to input the random engine states and\n"
371 <<
"the number of streams is greater than 1. Either set the\n"
372 <<
"parameter named \"restoreFileName\" in the RandomNumberGeneratorService\n"
373 <<
"to the empty string or set the parameter \"numberOfStreams\" in the top\n"
374 <<
"level options parameter set to 1. (Probably these are the default values\n"
375 <<
"and just not setting the parameters will also work)\n";
387 for(
unsigned int iStream = 0; iStream <
nStreams_; ++iStream) {
388 unsigned int seedOffset = iStream;
391 outFiles_[iStream] = std::make_shared<std::ofstream>();
394 for(
unsigned int iLumi = 0; iLumi < nConcurrentLumis; ++iLumi) {
421 <<
"Configuration is illegal. The RandomNumberGeneratorService is configured\n"
422 <<
"to run replay using a text file to input the random engine states and\n"
423 <<
"the process is configured to fork multiple processes. No forking is\n"
424 <<
"is allowed with this type of replay\n";
429 for(
auto& labelAndEngine : engines) {
430 std::map<std::string, SeedsAndName>::const_iterator seedsAndName =
seedsAndNameMap_.find(labelAndEngine.label());
433 seedsAndName->second.engineName(),
434 seedsAndName->second.seeds(),
439 if (kMaxChildren != 0) {
442 for(
auto& labelAndEngine : engines) {
443 std::map<std::string, SeedsAndName>::const_iterator seedsAndName =
seedsAndNameMap_.find(labelAndEngine.label());
446 seedsAndName->second.engineName(),
447 seedsAndName->second.seeds(),
456 std::ostringstream
suffix;
457 suffix <<
"_" << childIndex;
498 bool expected =
false;
502 reportSvc->reportRandomStateFile(fullName);
567 std::vector<RandomEngineState>
const&
572 std::vector<RandomEngineState>
const&
580 os <<
"\n\nRandomNumberGeneratorService dump\n\n";
582 os <<
" Contents of seedsAndNameMap (label moduleID engineType seeds)\n";
584 os <<
" " <<
entry.first
585 <<
" " <<
entry.second.moduleID()
586 <<
" " <<
entry.second.engineName();
587 for(
auto val :
entry.second.seeds()) {
592 os <<
" nStreams_ = " <<
nStreams_ <<
"\n";
599 os <<
" verbose_ = " <<
verbose_ <<
"\n";
603 os <<
"\n streamEngines_\n";
604 unsigned int iStream = 0;
606 os <<
" Stream " << iStream <<
"\n";
607 for(
auto const&
i :
k) {
608 os <<
" " <<
i.label();
609 for(
auto const&
j :
i.seeds()) {
612 os <<
" " <<
i.engine()->name();
613 if(
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
614 os <<
" " <<
i.engine()->getSeed();
616 os <<
" engine does not know seeds";
622 os <<
"\n lumiEngines_\n";
623 unsigned int iLumi = 0;
625 os <<
" lumiIndex " << iLumi <<
"\n";
626 for(
auto const&
i :
k) {
627 os <<
" " <<
i.label();
628 for(
auto const&
j :
i.seeds()) {
631 os <<
" " <<
i.engine()->name();
632 if(
i.engine()->name() ==
std::string(
"HepJamesRandom")) {
633 os <<
" " <<
i.engine()->getSeed();
635 os <<
" engine does not know seeds";
649 std::vector<ModuleIDToEngine>::iterator iter = std::lower_bound(moduleIDVector.begin(),
650 moduleIDVector.end(),
652 if(iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
654 iter->setEngineState(labelAndEngine->
engine()->put());
665 std::vector<ModuleIDToEngine>::iterator iter = std::lower_bound(moduleIDVector.begin(),
666 moduleIDVector.end(),
668 if(iter != moduleIDVector.end() && iter->moduleID() == moduleID) {
670 if(iter->engineState() != labelAndEngine->
engine()->put()) {
672 <<
"It is illegal to generate random numbers during beginStream, endStream,\n"
673 "beginRun, endRun, beginLumi, endLumi because that makes it very difficult\n"
674 "to replay the processing of individual events. Random numbers were\n"
675 "generated during one of these methods for the module with class name\n\""
690 <<
"In the configuration for the RandomNumberGeneratorService the\n"
691 <<
"restoreStateTag contains the current process which is illegal.\n"
692 <<
"The process name in the replay process should have been changed\n"
693 <<
"to be different than the original process name and the restoreStateTag\n"
694 <<
"should contain either the original process name or an empty process name.\n";
703 <<
"The RandomNumberGeneratorService is trying to restore\n"
704 <<
"the state of the random engines by reading a product from\n"
706 <<
"It could not find the product.\n"
707 <<
"Either the product in the LuminosityBlock was dropped or\n"
708 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
723 <<
"The RandomNumberGeneratorService is trying to restore\n"
724 <<
"the state of the random engines by reading a product from\n"
726 <<
"It could not find the product.\n"
727 <<
"Either the product in the Event was dropped or\n"
728 <<
"not produced or the configured input tag is incorrect or there is a bug somewhere\n";
736 cache.resize(engines.size());
737 std::vector<RandomEngineState>::iterator state = cache.begin();
739 for(std::vector<LabelAndEngine>::const_iterator iter = engines.begin();
740 iter != engines.end();
744 state->setLabel(label);
745 state->setSeed(iter->seeds());
747 std::vector<unsigned long> stateL = iter->engine()->put();
748 state->clearStateVector();
749 state->reserveStateVector(stateL.size());
750 for(
auto element : stateL) {
751 state->push_back_stateVector(static_cast<std::uint32_t>(element));
758 std::vector<LabelAndEngine>& engines) {
759 std::vector<LabelAndEngine>::iterator labelAndEngine = engines.begin();
760 for(
auto const& cachedState : cache) {
762 std::string const& engineLabel = cachedState.getLabel();
764 std::vector<std::uint32_t>
const& engineState = cachedState.getState();
765 std::vector<unsigned long> engineStateL;
766 engineStateL.reserve(engineState.size());
767 for(
auto const&
value : engineState) {
768 engineStateL.push_back(static_cast<unsigned long>(
value));
771 std::vector<std::uint32_t>
const& engineSeeds = cachedState.getSeed();
772 std::vector<long> engineSeedsL;
773 engineSeedsL.reserve(engineSeeds.size());
774 for(
auto const&
val : engineSeeds) {
775 long seedL =
static_cast<long>(
val);
776 engineSeedsL.push_back(seedL);
785 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
789 assert(labelAndEngine != engines.end() && engineLabel == labelAndEngine->label());
790 std::shared_ptr<CLHEP::HepRandomEngine>
const& engine = labelAndEngine->engine();
794 if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
799 engine->setSeed(engineSeedsL[0], 0);
800 engine->get(engineStateL);
802 labelAndEngine->setSeed(engineSeeds[0], 0);
803 }
else if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
808 engine->get(engineStateL);
810 labelAndEngine->setSeed(engineSeeds[0], 0);
811 labelAndEngine->setSeed(engineSeeds[1], 1);
812 }
else if(engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
817 engine->setSeed(engineSeedsL[0], 0);
818 engine->get(engineStateL);
820 labelAndEngine->setSeed(engineSeeds[0], 0);
825 <<
"The RandomNumberGeneratorService is trying to restore the state\n"
826 "of the random engines. The state in the event indicates an engine\n"
827 "of an unknown type. This should not be possible unless you are\n"
828 "running with an old code release on a new file that was created\n"
829 "with a newer release which had new engine types added. In this case\n"
830 "the only solution is to use a newer release. In any other case, notify\n"
831 "the EDM developers because this should not be possible\n";
841 if(typeFromConfig != typeFromEvent) {
843 <<
"The RandomNumberGeneratorService is trying to restore\n"
844 <<
"the state of the random engine for the module \""
845 << engineLabel <<
"\". An\n"
846 <<
"error was detected because the type of the engine in the\n"
847 <<
"input file and the configuration file do not match.\n"
848 <<
"In the configuration file the type is \"" << typeFromConfig
849 <<
"\".\nIn the input file the type is \"" << typeFromEvent <<
"\". If\n"
850 <<
"you are not generating any random numbers in this module, then\n"
851 <<
"remove the line in the configuration file that gives it\n"
852 <<
"a seed and the error will go away. Otherwise, you must give\n"
853 <<
"this module the same engine type in the configuration file or\n"
854 <<
"stop trying to restore the random engine state.\n";
865 if(!outFile.is_open()) {
866 std::stringstream
file;
869 file <<
"_" << streamID.
value();
876 <<
"Unable to open the file \""
877 << file.str() <<
"\" to save the state of the random engines.\n";
881 outFile.seekp(0, std::ios_base::beg);
882 outFile <<
"<RandomEngineStates>\n";
884 outFile <<
"<Event>\n";
886 outFile <<
"</Event>\n";
888 outFile <<
"<Lumi>\n";
890 outFile <<
"</Lumi>\n";
892 outFile <<
"</RandomEngineStates>\n";
899 for(std::vector<RandomEngineState>::const_iterator iter = v.begin(),
901 iter != iEnd; ++iter) {
903 std::vector<std::uint32_t>
const& seedVector = iter->getSeed();
906 std::vector<std::uint32_t>
const& stateVector = iter->getState();
909 outFile <<
"<ModuleLabel>\n" << iter->getLabel() <<
"\n</ModuleLabel>\n";
911 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n" ;
912 outFile <<
"<InitialSeeds>\n";
914 outFile <<
"</InitialSeeds>\n";
915 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
916 outFile <<
"<FullState>\n";
918 outFile <<
"</FullState>\n";
925 if(v.empty())
return;
926 size_t numItems = v.size();
927 for(
size_t i = 0;
i < numItems; ++
i) {
928 if(
i != 0 &&
i % 10 == 0) outFile <<
"\n";
929 outFile << std::setw(13) << v[
i];
943 std::vector<RandomEngineState>& cache) {
950 std::vector<RandomEngineState>& cache) {
958 std::vector<RandomEngineState>& cache,
960 std::ifstream inFile;
964 <<
"Unable to open the file \""
965 << fileName <<
"\" to restore the random engine states.\n";
970 if(!inFile.good() || text !=
std::string(
"<RandomEngineStates>")) {
972 <<
"Attempting to read file with random number engine states.\n"
974 <<
"\" is ill-structured or otherwise corrupted.\n"
975 <<
"Cannot read the file header word.\n";
977 bool saveToCache =
false;
982 std::vector<RandomEngineState>& cache,
989 std::vector<std::uint32_t> seedVector;
991 std::vector<std::uint32_t> stateVector;
1001 <<
"\" is ill-structured or otherwise corrupted.\n"
1002 <<
"Cannot read next field and did not hit the end yet.\n";
1006 if(leading ==
std::string(
"</RandomEngineStates>"))
return false;
1011 saveToCache =
false;
1018 saveToCache = (leading == whichStates);
1024 is >> moduleLabel >> trailing;
1030 <<
"\" is ill-structured or otherwise corrupted.\n"
1031 <<
"Cannot read a module label when restoring random engine states.\n";
1034 is >> leading >> seedVectorSize >> trailing;
1040 <<
"\" is ill-structured or otherwise corrupted.\n"
1041 <<
"Cannot read seed vector length when restoring random engine states.\n";
1049 <<
"\" is ill-structured or otherwise corrupted.\n"
1050 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1056 <<
"\" is ill-structured or otherwise corrupted.\n"
1057 <<
"The number of seeds exceeds 64K.\n";
1067 <<
"\" is ill-structured or otherwise corrupted.\n"
1068 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
1071 is >> leading >> stateVectorSize >> trailing;
1077 <<
"\" is ill-structured or otherwise corrupted.\n"
1078 <<
"Cannot read state vector length when restoring random engine states.\n";
1086 <<
"\" is ill-structured or otherwise corrupted.\n"
1087 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1093 <<
"\" is ill-structured or otherwise corrupted.\n"
1094 <<
"The number of states exceeds 64K.\n";
1097 readVector(is, stateVectorSize, stateVector);
1104 <<
"\" is ill-structured or otherwise corrupted.\n"
1105 <<
"Cannot read end of FullState when restoring random engine states.\n";
1110 randomEngineState.
setLabel(moduleLabel);
1111 std::vector<RandomEngineState>::iterator state =
1112 std::lower_bound(cache.begin(), cache.end(), randomEngineState);
1114 if(state != cache.end() && moduleLabel == state->getLabel()) {
1115 if(seedVector.size() != state->getSeed().size() ||
1116 stateVector.size() != state->getState().size()) {
1119 <<
"\" is ill-structured or otherwise corrupted.\n"
1120 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1122 state->setSeed(seedVector);
1123 state->setState(stateVector);
1132 v.reserve(numItems);
1134 for(
unsigned i = 0;
i < numItems; ++
i) {
1139 <<
"\" is ill-structured or otherwise corrupted.\n"
1140 <<
"Cannot read vector when restoring random engine states.\n";
1148 unsigned int seedOffset,
1149 unsigned int eventSeedOffset,
1150 std::vector<ModuleIDToEngine>& moduleIDVector) {
1157 unsigned int moduleID =
i.second.moduleID();
1161 VUint32 const& seeds =
i.second.seeds();
1163 if(name ==
"RanecuEngine") {
1164 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::RanecuEngine>();
1165 engines.emplace_back(label, seeds, engine);
1170 long int seedL =
static_cast<long int>(seeds[0]);
1172 if(name ==
"HepJamesRandom") {
1173 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<CLHEP::HepJamesRandom>(seedL);
1174 engines.emplace_back(label, seeds, engine);
1175 if(seedOffset != 0 || eventSeedOffset != 0) {
1187 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1188 assert(seeds[0] == seedu32);
1190 std::shared_ptr<CLHEP::HepRandomEngine> engine = std::make_shared<TRandomAdaptor>(seedL);
1191 engines.emplace_back(label, seeds, engine);
1192 if(seedOffset != 0 || eventSeedOffset != 0) {
1197 moduleIDVector.emplace_back(&engines.back(), moduleID);
1200 std::sort(moduleIDVector.begin(), moduleIDVector.end());
1207 std::uint32_t offset1,
1208 std::uint32_t offset2) {
1210 if(engineName ==
"RanecuEngine") {
1211 assert(seeds.size() == 2U);
1216 std::uint32_t seed0 = (seeds[0] + offset1) % mod;
1217 seed0 = (seed0 + offset2) % mod;
1218 labelAndEngine.
setSeed(seed0, 0);
1219 labelAndEngine.
setSeed(seeds[1], 1);
1221 seedL[0] =
static_cast<long int>(seed0);
1222 seedL[1] =
static_cast<long int>(seeds[1]);
1223 labelAndEngine.
engine()->setSeeds(seedL,0);
1225 assert(seeds.size() == 1U);
1227 if(engineName ==
"HepJamesRandom") {
1232 std::uint32_t seed0 = (seeds[0] + offset1) % mod;
1233 seed0 = (seed0 + offset2) % mod;
1234 labelAndEngine.
setSeed(seed0, 0);
1236 long int seedL =
static_cast<long int>(seed0);
1237 labelAndEngine.
engine()->setSeed(seedL, 0);
1239 assert(engineName ==
"TRandom3");
1244 std::uint32_t seed0 = seeds[0];
1245 if((max32 - seed0) >= offset1) {
1248 seed0 = offset1 - (max32 - seed0) - 1U;
1250 if((max32 - seed0) >= offset2) {
1253 seed0 = offset2 - (max32 - seed0) - 1U;
1255 labelAndEngine.
setSeed(seed0, 0);
1257 long seedL =
static_cast<long>(seed0);
1266 std::uint32_t seedu32 =
static_cast<std::uint32_t
>(seedL);
1267 assert(seed0 == seedu32);
1269 labelAndEngine.
engine()->setSeed(seedL, 0);
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)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &streamID) override
Use this engine in event methods.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static const std::uint32_t maxSeedRanecu
LuminosityBlockIndex index() const
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
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
std::shared_ptr< CLHEP::HepRandomEngine const > engine() 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)
void resetEngineSeeds(LabelAndEngine &labelAndEngine, std::string const &engineName, VUint32 const &seeds, std::uint32_t offset1, std::uint32_t offset2)
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)
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > outFiles_
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_
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)
std::vector< std::vector< RandomEngineState > > lumiCache_
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 watchPreModuleStreamEndLumi(PreModuleStreamEndLumi::slot_type const &iSlot)
void checkEngineType(std::string const &typeFromConfig, std::string const &typeFromEvent, std::string const &engineLabel) const
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)
virtual void consumes(ConsumesCollector &&iC) const override
void postModuleStreamEndLumi(StreamContext const &sc, ModuleCallingContext const &mcc)
static std::string const emptyString("")
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
StreamID streamID() const
void readLumiStatesFromTextFile(std::string const &fileName, std::vector< RandomEngineState > &cache)
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
virtual std::vector< RandomEngineState > const & getEventCache(StreamID const &) const override
void postModuleStreamBeginLumi(StreamContext const &sc, ModuleCallingContext const &mcc)