22 #include "CLHEP/Random/JamesRandom.h"
23 #include "CLHEP/Random/RanecuEngine.h"
24 #include "CLHEP/Random/engineIDulong.h"
49 restoreStateLabel_(pset.getUntrackedParameter<std::string>(
"restoreStateLabel")),
50 saveFileName_(pset.getUntrackedParameter<std::string>(
"saveFileName")),
51 saveFileNameRecorded_(
false),
52 restoreFileName_(pset.getUntrackedParameter<std::string>(
"restoreFileName")),
53 enableChecking_(pset.getUntrackedParameter<bool>(
"enableChecking")),
56 eventSeedOffset_(pset.getUntrackedParameter<unsigned>(
"eventSeedOffset")),
57 failedToFindStatesInLumi_(
false) {
61 <<
"In the configuration for the RandomNumberGeneratorService both\n"
62 <<
"restoreFileName and restoreStateLabel were set to nonempty values\n"
63 <<
"which is illegal. It is impossible to restore the random engine\n"
64 <<
"states two different ways in the same process.\n";
71 <<
"The saveFileName parameter must be a simple file name with no path\n"
72 <<
"specification. In the configuration, it was given the value \""
79 if (pset.
exists(
"moduleSeeds")) {
86 std::string engineName;
89 for (VString::const_iterator it = pSets.begin(), itEnd = pSets.end(); it != itEnd; ++it) {
92 engineName = modulePSet.
getUntrackedParameter<std::string>(
"engineName", std::string(
"HepJamesRandom"));
94 bool initialSeedExists = modulePSet.
exists(
"initialSeed");
95 bool initialSeedSetExists = modulePSet.
exists(
"initialSeedSet");
97 if (initialSeedExists && initialSeedSetExists) {
99 <<
"For the module with the label \"" << *it <<
"\",\n"
100 <<
"both the parameters \"initialSeed\" and \"initialSeedSet\"\n"
101 <<
"have been set in the configuration. You must set one or\n"
102 <<
"the other. It is illegal to set both.\n";
104 else if (!initialSeedExists && !initialSeedSetExists) {
106 <<
"For the module with the label \"" << *it <<
"\",\n"
107 <<
"neither the parameter \"initialSeed\" nor \"initialSeedSet\"\n"
108 <<
"has been set in the configuration. You must set one or\n"
111 else if (initialSeedExists) {
113 initialSeedSet.clear();
114 initialSeedSet.push_back(initialSeed);
116 else if (initialSeedSetExists) {
124 if (engineName == std::string(
"RanecuEngine")) {
125 if (initialSeedSet.size() != 2U) {
127 <<
"Random engines of type \"RanecuEngine\" require 2 seeds\n"
128 <<
"be specified with the parameter named \"initialSeedSet\".\n"
129 <<
"Either \"initialSeedSet\" was not in the configuration\n"
130 <<
"or its size was not 2 for the module with label \"" << *it <<
"\".\n" ;
132 boost::shared_ptr<CLHEP::HepRandomEngine> engine(
new CLHEP::RanecuEngine());
138 <<
"The RanecuEngine seeds should be in the range 0 to 2147483647.\n"
139 <<
"The seeds passed to the RandomNumberGenerationService from the\n"
140 "configuration file were " << initialSeedSet[0] <<
" and " << initialSeedSet[1]
141 <<
"\nThis was for the module with label \"" << *it <<
"\".\n";
144 seedL[0] =
static_cast<long int>(initialSeedSet[0]);
145 seedL[1] =
static_cast<long int>(initialSeedSet[1]);
146 engine->setSeeds(seedL,0);
150 if (initialSeedSet.size() != 1U) {
152 <<
"Random engines of type \"HepJamesRandom\" and \"TRandom3\n"
153 <<
"require exactly 1 seed be specified in the configuration.\n"
154 <<
"There were " << initialSeedSet.size() <<
" seeds set for the\n"
155 <<
"module with label \"" << *it <<
"\".\n" ;
157 long int seedL =
static_cast<long int>(initialSeedSet[0]);
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 " << *it <<
".\n";
167 boost::shared_ptr<CLHEP::HepRandomEngine> engine(
new CLHEP::HepJamesRandom(seedL));
170 else if(engineName ==
"TRandom3") {
179 uint32_t seedu32 =
static_cast<uint32_t
>(seedL);
180 assert(initialSeedSet[0] == seedu32);
182 boost::shared_ptr<CLHEP::HepRandomEngine> engine(
new TRandomAdaptor(seedL));
187 <<
"The random engine name, \"" << engineName
188 <<
"\", does not correspond to a supported engine.\n"
189 <<
"This engine was configured for the module with label \"" << *it <<
"\"";
234 CLHEP::HepRandomEngine&
240 <<
"The module with label \""
242 <<
"\" requested a random number engine from the \n"
243 "RandomNumberGeneratorService, but that module was not configured\n"
244 "for random numbers. An engine is created only if a seed(s) is provided\n"
245 "in the configuration file. Please add the following PSet to the\n"
246 "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";
256 <<
"Requested a random number engine from the RandomNumberGeneratorService\n"
257 "when no module was active. This is not supposed to be possible.\n"
258 "Please inform the edm developers about this. It would be helpful to\n"
259 "know the stack. If a source was requesting a random engine this could\n"
260 "happen. Sources are not supposed to be doing that anymore.\n";
269 std::map<std::string, VUint32>::const_iterator iter;
275 <<
"The module with label \""
277 <<
"\" requested a random number seed from the \n"
278 "RandomNumberGeneratorService, but that module was not configured\n"
279 "for random numbers. An engine is created only if a seed(s) is provided\n"
280 "in the configuration file. Please add the following PSet to the\n"
281 "configuration file for the RandomNumberGeneratorService:\n\n"
283 " initialSeed = cms.untracked.uint32(your_seed),\n"
284 " engineName = cms.untracked.string('TRandom3')\n"
286 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
287 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
291 <<
"Requested a random number seed from the RandomNumberGeneratorService\n"
292 "when no module was active. This is not supposed to be possible.\n"
293 "Please inform the edm developers about this. It would be helpful to\n"
294 "know the stack. If a source was requesting a random engine this could\n"
295 "happen. Sources are not supposed to be doing that anymore.\n";
298 return iter->second[0];
318 "match either nothing or one parameter named initialSeed. Either initialSeed will exist or "
319 "initialSeedSet will exist but not both. In the old deprecated interface, this will match "
320 "parameters with the names being the module labels and the values being the seeds");
321 val.addOptionalUntracked<std::vector<uint32_t> >(
"initialSeedSet")->setComment(
"New interface only");
322 val.addOptionalUntracked<std::string>(
"engineName",std::string(
"HepJamesRandom"))->setComment(
"New interface only");
325 wnode.
setComment(
"In the new interface, the name of each ParameterSet will be the associated module label. "
326 "In the old deprecated interface there will be one ParameterSet named moduleSeeds");
333 setComment(
"This parameter is deprecated, has no effect and will likely be completely removed someday");
335 descriptions.
add(
"RandomNumberGeneratorService", desc);
342 std::ostringstream
suffix;
343 suffix <<
"_" << childIndex;
421 reportSvc->reportRandomStateFile(fullName);
446 <<
"It is illegal to generate random numbers during module construction because \n"
447 "that makes it very difficult to reproduce the processing of individual\n"
448 "events. Random numbers were generated during module construction for the module with\n"
449 "class name \"" << description.
moduleName() <<
"\"\n"
450 "and module label \"" << description.
moduleLabel() <<
"\"\n";
470 <<
"It is illegal to generate random numbers during beginJob because \n"
471 "that makes it very difficult to reproduce the processing of individual\n"
472 "events. Random numbers were generated during beginJob for the module with\n"
473 "class name \"" << description.
moduleName() <<
"\"\n"
474 "and module label \"" << description.
moduleLabel() <<
"\"\n";
494 <<
"It is illegal to generate random numbers during beginRun because \n"
495 "that makes it very difficult to reproduce the processing of individual\n"
496 "events. Random numbers were generated during beginRun for the module with\n"
497 "class name \"" << description.
moduleName() <<
"\"\n"
498 "and module label \"" << description.
moduleLabel() <<
"\"\n";
538 <<
"It is illegal to generate random numbers during endLumi because \n"
539 "that makes it very difficult to reproduce the processing of individual\n"
540 "events. Random numbers were generated during endLumi for the module with\n"
541 "class name \"" << description.
moduleName() <<
"\"\n"
542 "and module label \"" << description.
moduleLabel() <<
"\"\n";
562 <<
"It is illegal to generate random numbers during endRun because \n"
563 "that makes it very difficult to reproduce the processing of individual\n"
564 "events. Random numbers were generated during endRun for the module with\n"
565 "class name \"" << description.
moduleName() <<
"\"\n"
566 "and module label \"" << description.
moduleLabel() <<
"\"\n";
586 <<
"It is illegal to generate random numbers during endJob because \n"
587 "that makes it very difficult to reproduce the processing of individual\n"
588 "events. Random numbers were generated during endJob for the module with\n"
589 "class name \"" << description.
moduleName() <<
"\"\n"
590 "and module label \"" << description.
moduleLabel() <<
"\"\n";
597 std::vector<RandomEngineState>
const&
602 std::vector<RandomEngineState>
const&
609 std::cout <<
"\n\nRandomNumberGeneratorService dump\n\n";
612 for (
std::map<std::string, std::vector<uint32_t> >::const_iterator iter =
seedMap_.begin();
616 std::vector<uint32_t> seeds = iter->second;
617 for (std::vector<uint32_t>::const_iterator vIter = seeds.begin();
618 vIter != seeds.end();
624 std::cout <<
"\n Contents of engineNameMap\n";
625 for (std::map<std::string, std::string>::const_iterator iter =
engineNameMap_.begin();
628 std::cout <<
" " << iter->first <<
" " << iter->second <<
"\n";
630 std::cout <<
"\n Contents of engineMap\n";
631 for (EngineMap::const_iterator iter =
engineMap_.begin();
635 <<
" " << iter->second->name() <<
" ";
636 if (iter->second->name() == std::string(
"HepJamesRandom")) {
640 std::cout <<
"Engine does not know original seed";
648 for (VString::const_iterator iter =
labelStack_.begin();
651 std::cout <<
" " << i <<
" " << *iter <<
"\n";
654 std::cout <<
" currentEngine points to end\n";
664 for (std::vector<EngineMap::const_iterator>::const_iterator iter =
engineStack_.begin();
668 std::cout <<
" " << i <<
" Points to end of engine map\n";
671 std::cout <<
" " << i <<
" " << (*iter)->first
672 <<
" " << (*iter)->second->name() <<
" " << (*iter)->second->getSeed() <<
"\n";
729 <<
"The RandomNumberGeneratorService is trying to restore\n"
730 <<
"the state of the random engines by reading a product from\n"
732 <<
"fails to find one. The label used in the request for the product\n"
733 <<
"is set in the configuration. It is probably set to the wrong value\n"
734 <<
"in the configuration file. It must match the module label\n"
735 <<
"of the RandomEngineStateProducer that created the product in\n"
736 <<
"a previous process\n";
741 <<
"The RandomNumberGeneratorService is trying to restore\n"
742 <<
"the state of the random engines by reading a product from\n"
744 <<
"It found the product in the Event but not the one in the LuminosityBlock.\n"
745 <<
"Either the product in the LuminosityBlock was dropped or\n"
746 <<
"there is a bug somewhere\n";
760 for (std::vector<RandomEngineState>::const_iterator
state = states->begin(),
761 iEnd = states->end();
764 std::vector<RandomEngineState>::iterator cachedState =
768 if (cachedState !=
eventCache_.end() && cachedState->getLabel() ==
state->getLabel()) {
769 if (cachedState->getSeed().size() !=
state->getSeed().size() ||
770 cachedState->getState().size() !=
state->getState().size()) {
772 <<
"In function RandomNumberGeneratorService::backwardCompatibilityRead.\n"
773 <<
"When attempting to replay processing with the RandomNumberGeneratorService,\n"
774 <<
"the engine type for each module must be the same in the replay configuration\n"
775 <<
"and the original configuration. If this is not the problem, then the data\n"
776 <<
"is somehow corrupted or there is a bug because the vector in the data containing\n"
777 <<
"the seeds or engine state is the incorrect size for the type of random engine.\n";
779 cachedState->setSeed(
state->getSeed());
780 cachedState->setState(
state->getState());
790 std::vector<RandomEngineState>::iterator
state = cache.begin();
792 for (EngineMap::const_iterator iter =
engineMap_.begin();
796 state->setLabel(iter->first);
797 state->setSeed(
seedMap_[iter->first]);
799 std::vector<unsigned long> stateL = iter->second->put();
800 state->clearStateVector();
801 state->reserveStateVector(stateL.size());
802 for (std::vector<unsigned long>::const_iterator vIter = stateL.begin();
803 vIter != stateL.end();
805 state->push_back_stateVector(static_cast<uint32_t>(*vIter));
812 for (std::vector<RandomEngineState>::const_iterator iter = cache.begin(),
814 iter != iEnd; ++iter) {
816 std::string
const& engineLabel = iter->getLabel();
818 std::vector<uint32_t>
const& engineState = iter->getState();
819 std::vector<unsigned long> engineStateL;
820 for (std::vector<uint32_t>::const_iterator iVal = engineState.begin(),
821 theEnd = engineState.end();
822 iVal != theEnd; ++iVal) {
823 engineStateL.push_back(static_cast<unsigned long>(*iVal));
826 std::vector<uint32_t>
const& engineSeeds = iter->getSeed();
827 std::vector<long> engineSeedsL;
828 for (std::vector<uint32_t>::const_iterator iVal = engineSeeds.begin(),
829 theEnd = engineSeeds.end();
832 long seedL =
static_cast<long>(*iVal);
833 engineSeedsL.push_back(seedL);
842 uint32_t seedu32 =
static_cast<uint32_t
>(seedL);
843 assert(*iVal == seedu32);
846 EngineMap::iterator engine =
engineMap_.find(engineLabel);
850 seedMap_[engineLabel] = engineSeeds;
854 if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
856 checkEngineType(engine->second->name(), std::string(
"HepJamesRandom"), engineLabel);
859 engine->second->setSeed(engineSeedsL[0], 0);
860 engine->second->get(engineStateL);
862 else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
864 checkEngineType(engine->second->name(), std::string(
"RanecuEngine"), engineLabel);
867 engine->second->get(engineStateL);
869 else if (engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
871 checkEngineType(engine->second->name(), std::string(
"TRandom3"), engineLabel);
874 engine->second->setSeed(engineSeedsL[0], 0);
875 engine->second->get(engineStateL);
881 <<
"The RandomNumberGeneratorService is trying to restore the state\n"
882 "of the random engines. The state in the event indicates an engine\n"
883 "of an unknown type. This should not be possible unless you are\n"
884 "running with an old code release on a new file that was created\n"
885 "with a newer release which had new engine types added. In this case\n"
886 "the only solution is to use a newer release. In any other case, notify\n"
887 "the EDM developers because this should not be possible\n";
895 std::string
const& typeFromEvent,
896 std::string
const& engineLabel)
898 if (typeFromConfig != typeFromEvent) {
900 <<
"The RandomNumberGeneratorService is trying to restore\n"
901 <<
"the state of the random engine for the module \""
902 << engineLabel <<
"\". An\n"
903 <<
"error was detected because the type of the engine in the\n"
904 <<
"input file and the configuration file do not match.\n"
905 <<
"In the configuration file the type is \"" << typeFromConfig
906 <<
"\".\nIn the input file the type is \"" << typeFromEvent <<
"\". If\n"
907 <<
"you are not generating any random numbers in this module, then\n"
908 <<
"remove the line in the configuration file that gives it\n"
909 <<
"a seed and the error will go away. Otherwise, you must give\n"
910 <<
"this module the same engine type in the configuration file or\n"
911 <<
"stop trying to restore the random engine state.\n";
918 std::ofstream outFile;
922 <<
"Unable to open the file \""
923 << fileName <<
"\" to save the state of the random engines.\n";
925 outFile <<
"<RandomEngineStates>\n";
927 outFile <<
"<Event>\n";
929 outFile <<
"</Event>\n" ;
931 outFile <<
"<Lumi>\n";
933 outFile <<
"</Lumi>\n" ;
935 outFile <<
"</RandomEngineStates>\n" ;
940 std::ofstream & outFile) {
941 for (std::vector<RandomEngineState>::const_iterator iter = v.begin(),
943 iter != iEnd; ++iter) {
945 std::vector<uint32_t>
const& seedVector = iter->getSeed();
948 std::vector<uint32_t>
const& stateVector = iter->getState();
951 outFile <<
"<ModuleLabel>\n" << iter->getLabel() <<
"\n</ModuleLabel>\n";
953 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n" ;
954 outFile <<
"<InitialSeeds>\n";
956 outFile <<
"</InitialSeeds>\n";
957 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
958 outFile <<
"<FullState>\n";
960 outFile <<
"</FullState>\n";
966 std::ofstream & outFile)
968 if (v.empty())
return;
969 size_t numItems = v.size();
970 for (
size_t i = 0;
i < numItems; ++
i) {
971 if (
i != 0 &&
i % 10 == 0) outFile <<
"\n";
972 outFile << std::setw(13) << v[
i];
980 std::string
fullName(getcwd(directory,
sizeof(directory)) ? directory :
"/PathIsTooBig");
987 std::string whichStates(
"<Event>");
993 std::string whichStates(
"<Lumi>");
1000 std::vector<RandomEngineState> & cache,
1001 std::string
const& whichStates) {
1002 std::ifstream inFile;
1006 <<
"Unable to open the file \""
1007 << fileName <<
"\" to restore the random engine states.\n";
1012 if (!inFile.good() || text != std::string(
"<RandomEngineStates>")) {
1014 <<
"Attempting to read file with random number engine states.\n"
1016 <<
"\" is ill-structured or otherwise corrupted.\n"
1017 <<
"Cannot read the file header word.\n";
1019 bool saveToCache =
false;
1024 std::vector<RandomEngineState> & cache,
1025 std::string
const& whichStates,
1026 bool & saveToCache) {
1027 std::string leading;
1028 std::string trailing;
1031 std::vector<uint32_t> seedVector;
1033 std::vector<uint32_t> stateVector;
1043 <<
"\" is ill-structured or otherwise corrupted.\n"
1044 <<
"Cannot read next field and did not hit the end yet.\n";
1048 if (leading == std::string(
"</RandomEngineStates>"))
return false;
1051 if (leading == std::string(
"</Event>") ||
1052 leading == std::string(
"</Lumi>")) {
1053 saveToCache =
false;
1058 if (leading == std::string(
"<Event>") ||
1059 leading == std::string(
"<Lumi>")) {
1060 saveToCache = (leading == whichStates);
1066 is >> moduleLabel >> trailing;
1068 leading != std::string(
"<ModuleLabel>") ||
1069 trailing != std::string(
"</ModuleLabel>")) {
1072 <<
"\" is ill-structured or otherwise corrupted.\n"
1073 <<
"Cannot read a module label when restoring random engine states.\n";
1076 is >> leading >> seedVectorSize >> trailing;
1078 leading != std::string(
"<SeedLength>") ||
1079 trailing != std::string(
"</SeedLength>")) {
1082 <<
"\" is ill-structured or otherwise corrupted.\n"
1083 <<
"Cannot read seed vector length when restoring random engine states.\n";
1088 leading != std::string(
"<InitialSeeds>")) {
1091 <<
"\" is ill-structured or otherwise corrupted.\n"
1092 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1099 trailing != std::string(
"</InitialSeeds>")) {
1102 <<
"\" is ill-structured or otherwise corrupted.\n"
1103 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
1106 is >> leading >> stateVectorSize >> trailing;
1108 leading != std::string(
"<FullStateLength>") ||
1109 trailing != std::string(
"</FullStateLength>")) {
1112 <<
"\" is ill-structured or otherwise corrupted.\n"
1113 <<
"Cannot read state vector length when restoring random engine states.\n";
1118 leading != std::string(
"<FullState>")) {
1121 <<
"\" is ill-structured or otherwise corrupted.\n"
1122 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1125 readVector(is, stateVectorSize, stateVector);
1129 trailing != std::string(
"</FullState>")) {
1132 <<
"\" is ill-structured or otherwise corrupted.\n"
1133 <<
"Cannot read end of FullState when restoring random engine states.\n";
1138 randomEngineState.
setLabel(moduleLabel);
1139 std::vector<RandomEngineState>::iterator
state =
1140 std::lower_bound(cache.begin(), cache.end(), randomEngineState);
1142 if (state != cache.end() && moduleLabel == state->getLabel()) {
1143 if (seedVector.size() != state->getSeed().size() ||
1144 stateVector.size() != state->getState().size()) {
1147 <<
"\" is ill-structured or otherwise corrupted.\n"
1148 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1150 state->setSeed(seedVector);
1151 state->setState(stateVector);
1160 v.reserve(numItems);
1162 for (
unsigned i = 0;
i < numItems; ++
i) {
1167 <<
"\" is ill-structured or otherwise corrupted.\n"
1168 <<
"Cannot read vector when restoring random engine states.\n";
1179 for (EngineMap::const_iterator iter =
engineMap_.begin();
1190 if (engineName == std::string(
"RanecuEngine")) {
1191 assert(seeds.size() == 2U);
1194 offset1 = offset1 %
mod;
1195 offset2 = offset2 %
mod;
1196 seeds[0] = (seeds[0] + offset1) % mod;
1197 seeds[0] = (seeds[0] + offset2) % mod;
1199 seedL[0] =
static_cast<long int>(seeds[0]);
1200 seedL[1] =
static_cast<long int>(seeds[1]);
1201 iter->second->setSeeds(seedL,0);
1204 assert(seeds.size() == 1U);
1206 if (engineName ==
"HepJamesRandom") {
1209 offset1 = offset1 %
mod;
1210 offset2 = offset2 %
mod;
1211 seeds[0] = (seeds[0] + offset1) % mod;
1212 seeds[0] = (seeds[0] + offset2) % mod;
1214 long int seedL =
static_cast<long int>(seeds[0]);
1215 iter->second->setSeed(seedL, 0);
1218 assert(engineName ==
"TRandom3");
1223 if ((max32 - seeds[0]) >= offset1) {
1224 seeds[0] = seeds[0] + offset1;
1227 seeds[0] = offset1 - (max32 - seeds[0]) - 1U;
1229 if ((max32 - seeds[0]) >= offset2) {
1230 seeds[0] = seeds[0] + offset2;
1233 seeds[0] = offset2 - (max32 - seeds[0]) - 1U;
1235 long seedL =
static_cast<long>(seeds[0]);
1244 uint32_t seedu32 =
static_cast<uint32_t
>(seedL);
1245 assert(seeds[0] == seedu32);
1247 iter->second->setSeed(seedL, 0);
1256 for (VString::const_iterator it = pSets.begin(), itEnd = pSets.end(); it != itEnd; ++it) {
1257 if (*it != std::string(
"moduleSeeds")) {
1259 <<
"RandomNumberGeneratorService supports two configuration interfaces.\n"
1260 <<
"One is old and deprecated, but still supported for backward compatibility\n"
1261 <<
"reasons. It is illegal to mix parameters using both the old and new service\n"
1262 <<
"interface in the same configuration. It is assumed the old interface is being\n"
1263 <<
"used if the parameter set named \"moduleSeeds\" exists. In that case it is\n"
1264 <<
"illegal to have any other nested ParameterSets. This exception was thrown\n"
1265 <<
"because that happened.\n";
1271 std::vector<uint32_t> seeds;
1274 for (VString::const_iterator itName = names.begin(), itNameEnd = names.end();
1275 itName != itNameEnd; ++itName) {
1280 seeds.push_back(seed);
1286 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to 900000000.\n"
1287 <<
"The seed passed to the RandomNumberGenerationService from the\n"
1288 "configuration file was " << seed <<
". This was for the module\n"
1289 <<
"with label \"" << *itName <<
"\".";
1291 long seedL =
static_cast<long>(seed);
1292 engineMap_[*itName] = boost::shared_ptr<CLHEP::HepRandomEngine>(
new CLHEP::HepJamesRandom(seedL));
void watchPostModuleConstruction(PostModuleConstruction::slot_type const &iSlot)
void writeStates(std::vector< RandomEngineState > const &v, std::ofstream &outFile)
void setComment(std::string const &value)
T getUntrackedParameter(std::string const &, T const &) const
static uint32_t maxSeedHepJames
void restoreFromCache(std::vector< RandomEngineState > const &cache)
void watchPostModuleBeginLumi(PostModuleBeginLumi::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::string currentLabel_
void postModuleEndJob(ModuleDescription const &description)
void preModuleEndLumi(ModuleDescription const &description)
bool backwardCompatibilityRead(Event const &event)
void readFromEvent(Event const &event)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void watchPostModule(PostModule::slot_type const &iSlot)
virtual void print()
For debugging purposes only.
void setLabel(const std::string &value)
std::vector< std::vector< unsigned long > > engineStateStack_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static uint32_t maxSeedTRandom3
std::string const & moduleName() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
virtual void postEventRead(Event const &event)
void preModuleConstruction(ModuleDescription const &description)
void postModuleEndLumi(ModuleDescription const &description)
void preModule(ModuleDescription const &description)
void postBeginLumi(LuminosityBlock const &lumi, EventSetup const &es)
void postModule(ModuleDescription const &description)
void watchPreModuleEndLumi(PreModuleEndLumi::slot_type const &iSlot)
void preModuleBeginJob(ModuleDescription const &description)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
void readFromLuminosityBlock(LuminosityBlock const &lumi)
void readLumiStatesFromTextFile(std::string const &fileName)
std::map< std::string, std::string > engineNameMap_
std::string const & moduleLabel() const
void checkEngineType(std::string const &typeFromConfig, std::string const &typeFromEvent, std::string const &engineLabel)
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void oldStyleConfig(ParameterSet const &pset)
void watchPreModule(PreModule::slot_type const &iSlot)
void preModuleBeginLumi(ModuleDescription const &description)
std::string saveFileName_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
void saveStatesToFile(std::string const &fileName)
void postModuleBeginRun(ModuleDescription const &description)
void watchPreModuleEndRun(PreModuleEndRun::slot_type const &iSlot)
virtual CLHEP::HepRandomEngine & getEngine() const
Use this to get the random number engine, this is the only function most users should call...
RandomNumberGeneratorService(ParameterSet const &pset, ActivityRegistry &activityRegistry)
virtual std::vector< RandomEngineState > const & getEventCache() const
void postModuleEndRun(ModuleDescription const &description)
bool readEngineState(std::istream &is, std::vector< RandomEngineState > &cache, std::string const &whichStates, bool &saveToCache)
virtual uint32_t mySeed() const
Exists for backward compatibility.
void watchPostModuleEndRun(PostModuleEndRun::slot_type const &iSlot)
void readEventStatesFromTextFile(std::string const &fileName)
void watchPreModuleEndJob(PreModuleEndJob::slot_type const &iSlot)
virtual void preBeginLumi(LuminosityBlock const &lumi)
bool failedToFindStatesInLumi_
std::vector< RandomEngineState > eventCache_
void readStatesFromFile(std::string const &fileName, std::vector< RandomEngineState > &cache, std::string const &whichStates)
void snapShot(std::vector< RandomEngineState > &cache)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::vector< std::string > getParameterNames() const
void watchPostBeginLumi(PostBeginLumi::slot_type const &iSlot)
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 watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
void push(std::string const &iLabel)
void postModuleBeginJob(ModuleDescription const &description)
std::vector< EngineMap::const_iterator > engineStack_
void watchPostModuleBeginRun(PostModuleBeginRun::slot_type const &iSlot)
virtual std::vector< RandomEngineState > const & getLumiCache() const
void preModuleEndRun(ModuleDescription const &description)
void startNewSequencesForEvents()
std::vector< RandomEngineState > lumiCache_
std::map< std::string, VUint32 > seedMap_
ParameterSet const & getParameterSet(std::string const &) const
void postModuleBeginLumi(ModuleDescription const &description)
void preModuleEndJob(ModuleDescription const &description)
std::vector< std::string > VString
void postForkReacquireResources(unsigned childIndex, unsigned kMaxChildren)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void readVector(std::istream &is, unsigned numItems, std::vector< uint32_t > &v)
void postModuleConstruction(ModuleDescription const &description)
static uint32_t maxSeedRanecu
static std::string const emptyString("")
void watchPostForkReacquireResources(PostForkReacquireResources::slot_type const &iSlot)
virtual ~RandomNumberGeneratorService()
EngineMap::const_iterator currentEngine_
void writeVector(VUint32 const &v, std::ofstream &outFile)
std::string restoreFileName_
void watchPostModuleBeginJob(PostModuleBeginJob::slot_type const &iSlot)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
void watchPreModuleBeginLumi(PreModuleBeginLumi::slot_type const &iSlot)
void preModuleBeginRun(ModuleDescription const &description)
T mod(const T &a, const T &b)
static const HistoName names[]
void watchPostModuleEndJob(PostModuleEndJob::slot_type const &iSlot)
void watchPreModuleBeginRun(PreModuleBeginRun::slot_type const &iSlot)
std::vector< uint32_t > VUint32
uint32_t eventSeedOffset_
void watchPostModuleEndLumi(PostModuleEndLumi::slot_type const &iSlot)
std::string constructSaveFileName()
bool saveFileNameRecorded_
std::string restoreStateLabel_
const std::string * moduleLabel() const