30 #include "CLHEP/Random/engineIDulong.h"
31 #include "CLHEP/Random/JamesRandom.h"
32 #include "CLHEP/Random/RanecuEngine.h"
48 saveFileName_(pset.getUntrackedParameter<std::string>(
"saveFileName")),
49 saveFileNameRecorded_(
false),
50 restoreFileName_(pset.getUntrackedParameter<std::string>(
"restoreFileName")),
51 enableChecking_(pset.getUntrackedParameter<bool>(
"enableChecking")),
54 eventSeedOffset_(pset.getUntrackedParameter<unsigned>(
"eventSeedOffset")),
55 failedToFindStatesInLumi_(
false) {
57 if(pset.
exists(
"restoreStateTag")) {
66 <<
"In the configuration for the RandomNumberGeneratorService both\n"
67 <<
"restoreFileName and restoreStateLabel were set to nonempty values\n"
68 <<
"which is illegal. It is impossible to restore the random engine\n"
69 <<
"states two different ways in the same process.\n";
76 <<
"The saveFileName parameter must be a simple file name with no path\n"
77 <<
"specification. In the configuration, it was given the value \""
84 if(pset.
exists(
"moduleSeeds")) {
90 std::string engineName;
93 for(VString::const_iterator it = pSets.begin(), itEnd = pSets.end(); it != itEnd; ++it) {
96 engineName = modulePSet.
getUntrackedParameter<std::string>(
"engineName", std::string(
"HepJamesRandom"));
98 bool initialSeedExists = modulePSet.
exists(
"initialSeed");
99 bool initialSeedSetExists = modulePSet.
exists(
"initialSeedSet");
101 if(initialSeedExists && initialSeedSetExists) {
103 <<
"For the module with the label \"" << *it <<
"\",\n"
104 <<
"both the parameters \"initialSeed\" and \"initialSeedSet\"\n"
105 <<
"have been set in the configuration. You must set one or\n"
106 <<
"the other. It is illegal to set both.\n";
107 }
else if(!initialSeedExists && !initialSeedSetExists) {
109 <<
"For the module with the label \"" << *it <<
"\",\n"
110 <<
"neither the parameter \"initialSeed\" nor \"initialSeedSet\"\n"
111 <<
"has been set in the configuration. You must set one or\n"
113 }
else if(initialSeedExists) {
115 initialSeedSet.clear();
116 initialSeedSet.push_back(initialSeed);
117 }
else if(initialSeedSetExists) {
125 if(engineName == std::string(
"RanecuEngine")) {
126 if(initialSeedSet.size() != 2U) {
128 <<
"Random engines of type \"RanecuEngine\" require 2 seeds\n"
129 <<
"be specified with the parameter named \"initialSeedSet\".\n"
130 <<
"Either \"initialSeedSet\" was not in the configuration\n"
131 <<
"or its size was not 2 for the module with label \"" << *it <<
"\".\n" ;
133 boost::shared_ptr<CLHEP::HepRandomEngine> engine(
new CLHEP::RanecuEngine());
139 <<
"The RanecuEngine seeds should be in the range 0 to 2147483647.\n"
140 <<
"The seeds passed to the RandomNumberGenerationService from the\n"
141 "configuration file were " << initialSeedSet[0] <<
" and " << initialSeedSet[1]
142 <<
"\nThis was for the module with label \"" << *it <<
"\".\n";
145 seedL[0] =
static_cast<long int>(initialSeedSet[0]);
146 seedL[1] =
static_cast<long int>(initialSeedSet[1]);
147 engine->setSeeds(seedL, 0);
151 if(initialSeedSet.size() != 1U) {
153 <<
"Random engines of type \"HepJamesRandom\" and \"TRandom3\n"
154 <<
"require exactly 1 seed be specified in the configuration.\n"
155 <<
"There were " << initialSeedSet.size() <<
" seeds set for the\n"
156 <<
"module with label \"" << *it <<
"\".\n" ;
158 long int seedL =
static_cast<long int>(initialSeedSet[0]);
160 if(engineName ==
"HepJamesRandom") {
163 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to 900000000.\n"
164 <<
"The seed passed to the RandomNumberGenerationService from the\n"
165 "configuration file was " << initialSeedSet[0] <<
". This was for \n"
166 <<
"the module with label " << *it <<
".\n";
168 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));
186 <<
"The random engine name, \"" << engineName
187 <<
"\", does not correspond to a supported engine.\n"
188 <<
"This engine was configured for the module with label \"" << *it <<
"\"";
233 CLHEP::HepRandomEngine&
239 <<
"The module with label \""
241 <<
"\" requested a random number engine from the \n"
242 "RandomNumberGeneratorService, but that module was not configured\n"
243 "for random numbers. An engine is created only if a seed(s) is provided\n"
244 "in the configuration file. Please add the following PSet to the\n"
245 "configuration file for the RandomNumberGeneratorService:\n\n"
247 " initialSeed = cms.untracked.uint32(your_seed),\n"
248 " engineName = cms.untracked.string('TRandom3')\n"
250 "where you replace \"your_seed\" with a number and add a comma if necessary\n"
251 "The \"engineName\" parameter is optional. If absent the default is \"HepJamesRandom\".\n";
254 <<
"Requested a random number engine from the RandomNumberGeneratorService\n"
255 "when no module was active. This is not supposed to be possible.\n"
256 "Please inform the edm developers about this. It would be helpful to\n"
257 "know the stack. If a source was requesting a random engine this could\n"
258 "happen. Sources are not supposed to be doing that anymore.\n";
267 std::map<std::string, VUint32>::const_iterator iter;
273 <<
"The module with label \""
275 <<
"\" requested a random number seed 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 <<
"Requested a random number seed from the RandomNumberGeneratorService\n"
289 "when no module was active. This is not supposed to be possible.\n"
290 "Please inform the edm developers about this. It would be helpful to\n"
291 "know the stack. If a source was requesting a random engine this could\n"
292 "happen. Sources are not supposed to be doing that anymore.\n";
295 return iter->second[0];
319 "match either nothing or one parameter named initialSeed. Either initialSeed will exist or "
320 "initialSeedSet will exist but not both. In the old deprecated interface, this will match "
321 "parameters with the names being the module labels and the values being the seeds");
322 val.addOptionalUntracked<std::vector<uint32_t> >(
"initialSeedSet")->setComment(
"New interface only");
323 val.addOptionalUntracked<std::string>(
"engineName",std::string(
"HepJamesRandom"))->setComment(
"New interface only");
326 wnode.
setComment(
"In the new interface, the name of each ParameterSet will be the associated module label. "
327 "In the old deprecated interface there will be one ParameterSet named moduleSeeds");
334 setComment(
"This parameter is deprecated, has no effect and will likely be completely removed someday");
336 descriptions.
add(
"RandomNumberGeneratorService", desc);
344 std::ostringstream
suffix;
345 suffix <<
"_" << childIndex;
422 reportSvc->reportRandomStateFile(fullName);
445 <<
"It is illegal to generate random numbers during module construction because \n"
446 "that makes it very difficult to reproduce the processing of individual\n"
447 "events. Random numbers were generated during module construction for the module with\n"
448 "class name \"" << description.
moduleName() <<
"\"\n"
449 "and module label \"" << description.
moduleLabel() <<
"\"\n";
469 <<
"It is illegal to generate random numbers during beginJob because \n"
470 "that makes it very difficult to reproduce the processing of individual\n"
471 "events. Random numbers were generated during beginJob for the module with\n"
472 "class name \"" << description.
moduleName() <<
"\"\n"
473 "and module label \"" << description.
moduleLabel() <<
"\"\n";
493 <<
"It is illegal to generate random numbers during beginRun because \n"
494 "that makes it very difficult to reproduce the processing of individual\n"
495 "events. Random numbers were generated during beginRun for the module with\n"
496 "class name \"" << description.
moduleName() <<
"\"\n"
497 "and module label \"" << description.
moduleLabel() <<
"\"\n";
537 <<
"It is illegal to generate random numbers during endLumi because \n"
538 "that makes it very difficult to reproduce the processing of individual\n"
539 "events. Random numbers were generated during endLumi for the module with\n"
540 "class name \"" << description.
moduleName() <<
"\"\n"
541 "and module label \"" << description.
moduleLabel() <<
"\"\n";
561 <<
"It is illegal to generate random numbers during endRun because \n"
562 "that makes it very difficult to reproduce the processing of individual\n"
563 "events. Random numbers were generated during endRun for the module with\n"
564 "class name \"" << description.
moduleName() <<
"\"\n"
565 "and module label \"" << description.
moduleLabel() <<
"\"\n";
585 <<
"It is illegal to generate random numbers during endJob because \n"
586 "that makes it very difficult to reproduce the processing of individual\n"
587 "events. Random numbers were generated during endJob for the module with\n"
588 "class name \"" << description.
moduleName() <<
"\"\n"
589 "and module label \"" << description.
moduleLabel() <<
"\"\n";
596 std::vector<RandomEngineState>
const&
601 std::vector<RandomEngineState>
const&
608 std::cout <<
"\n\nRandomNumberGeneratorService dump\n\n";
611 for(
std::map<std::string, std::vector<uint32_t> >::const_iterator iter =
seedMap_.begin();
615 std::vector<uint32_t> seeds = iter->second;
616 for(std::vector<uint32_t>::const_iterator vIter = seeds.begin();
617 vIter != seeds.end();
623 std::cout <<
"\n Contents of engineNameMap\n";
624 for(std::map<std::string, std::string>::const_iterator iter =
engineNameMap_.begin();
627 std::cout <<
" " << iter->first <<
" " << iter->second <<
"\n";
629 std::cout <<
"\n Contents of engineMap\n";
630 for(EngineMap::const_iterator iter =
engineMap_.begin();
634 <<
" " << iter->second->name() <<
" ";
635 if(iter->second->name() == std::string(
"HepJamesRandom")) {
638 std::cout <<
"Engine does not know original seed";
646 for(VString::const_iterator iter =
labelStack_.begin();
649 std::cout <<
" " << i <<
" " << *iter <<
"\n";
652 std::cout <<
" currentEngine points to end\n";
661 for(std::vector<EngineMap::const_iterator>::const_iterator iter =
engineStack_.begin();
665 std::cout <<
" " << i <<
" Points to end of engine map\n";
667 std::cout <<
" " << i <<
" " << (*iter)->first
668 <<
" " << (*iter)->second->name() <<
" " << (*iter)->second->getSeed() <<
"\n";
721 <<
"The RandomNumberGeneratorService is trying to restore\n"
722 <<
"the state of the random engines by reading a product from\n"
724 <<
"fails to find one. The label used in the request for the product\n"
725 <<
"is set in the configuration. It is probably set to the wrong value\n"
726 <<
"in the configuration file. It must match the module label\n"
727 <<
"of the RandomEngineStateProducer that created the product in\n"
728 <<
"a previous process\n";
733 <<
"The RandomNumberGeneratorService is trying to restore\n"
734 <<
"the state of the random engines by reading a product from\n"
735 <<
"the Event and LuminosityBlock with input tag \"" <<
restoreStateTag_ <<
"\".\n"
736 <<
"It found the product in the Event but not the one in the LuminosityBlock.\n"
737 <<
"Either the product in the LuminosityBlock was dropped or\n"
738 <<
"there is a bug somewhere\n";
752 for(std::vector<RandomEngineState>::const_iterator
state = states->begin(),
753 iEnd = states->end();
756 std::vector<RandomEngineState>::iterator cachedState =
760 if(cachedState !=
eventCache_.end() && cachedState->getLabel() ==
state->getLabel()) {
761 if(cachedState->getSeed().size() !=
state->getSeed().size() ||
762 cachedState->getState().size() !=
state->getState().size()) {
764 <<
"In function RandomNumberGeneratorService::backwardCompatibilityRead.\n"
765 <<
"When attempting to replay processing with the RandomNumberGeneratorService,\n"
766 <<
"the engine type for each module must be the same in the replay configuration\n"
767 <<
"and the original configuration. If this is not the problem, then the data\n"
768 <<
"is somehow corrupted or there is a bug because the vector in the data containing\n"
769 <<
"the seeds or engine state is the incorrect size for the type of random engine.\n";
771 cachedState->setSeed(
state->getSeed());
772 cachedState->setState(
state->getState());
781 std::vector<RandomEngineState>::iterator
state = cache.begin();
783 for(EngineMap::const_iterator iter =
engineMap_.begin();
787 state->setLabel(iter->first);
788 state->setSeed(
seedMap_[iter->first]);
790 std::vector<unsigned long> stateL = iter->second->put();
791 state->clearStateVector();
792 state->reserveStateVector(stateL.size());
793 for(std::vector<unsigned long>::const_iterator vIter = stateL.begin();
794 vIter != stateL.end();
796 state->push_back_stateVector(static_cast<uint32_t>(*vIter));
803 for(std::vector<RandomEngineState>::const_iterator iter = cache.begin(),
805 iter != iEnd; ++iter) {
807 std::string
const& engineLabel = iter->getLabel();
809 std::vector<uint32_t>
const& engineState = iter->getState();
810 std::vector<unsigned long> engineStateL;
811 for(std::vector<uint32_t>::const_iterator iVal = engineState.begin(),
812 theEnd = engineState.end();
813 iVal != theEnd; ++iVal) {
814 engineStateL.push_back(static_cast<unsigned long>(*iVal));
817 std::vector<uint32_t>
const& engineSeeds = iter->getSeed();
818 std::vector<long> engineSeedsL;
819 for(std::vector<uint32_t>::const_iterator iVal = engineSeeds.begin(),
820 theEnd = engineSeeds.end();
823 long seedL =
static_cast<long>(*iVal);
824 engineSeedsL.push_back(seedL);
833 uint32_t seedu32 =
static_cast<uint32_t
>(seedL);
834 assert(*iVal == seedu32);
837 EngineMap::iterator engine =
engineMap_.find(engineLabel);
841 seedMap_[engineLabel] = engineSeeds;
845 if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
847 checkEngineType(engine->second->name(), std::string(
"HepJamesRandom"), engineLabel);
850 engine->second->setSeed(engineSeedsL[0], 0);
851 engine->second->get(engineStateL);
852 }
else if(engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
854 checkEngineType(engine->second->name(), std::string(
"RanecuEngine"), engineLabel);
857 engine->second->get(engineStateL);
858 }
else if(engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
860 checkEngineType(engine->second->name(), std::string(
"TRandom3"), engineLabel);
863 engine->second->setSeed(engineSeedsL[0], 0);
864 engine->second->get(engineStateL);
869 <<
"The RandomNumberGeneratorService is trying to restore the state\n"
870 "of the random engines. The state in the event indicates an engine\n"
871 "of an unknown type. This should not be possible unless you are\n"
872 "running with an old code release on a new file that was created\n"
873 "with a newer release which had new engine types added. In this case\n"
874 "the only solution is to use a newer release. In any other case, notify\n"
875 "the EDM developers because this should not be possible\n";
883 std::string
const& typeFromEvent,
884 std::string
const& engineLabel) {
885 if(typeFromConfig != typeFromEvent) {
887 <<
"The RandomNumberGeneratorService is trying to restore\n"
888 <<
"the state of the random engine for the module \""
889 << engineLabel <<
"\". An\n"
890 <<
"error was detected because the type of the engine in the\n"
891 <<
"input file and the configuration file do not match.\n"
892 <<
"In the configuration file the type is \"" << typeFromConfig
893 <<
"\".\nIn the input file the type is \"" << typeFromEvent <<
"\". If\n"
894 <<
"you are not generating any random numbers in this module, then\n"
895 <<
"remove the line in the configuration file that gives it\n"
896 <<
"a seed and the error will go away. Otherwise, you must give\n"
897 <<
"this module the same engine type in the configuration file or\n"
898 <<
"stop trying to restore the random engine state.\n";
909 <<
"Unable to open the file \""
910 << fileName <<
"\" to save the state of the random engines.\n";
912 outFile_.seekp(0, std::ios_base::beg);
913 outFile_ <<
"<RandomEngineStates>\n";
923 outFile_ <<
"</RandomEngineStates>\n" ;
930 for(std::vector<RandomEngineState>::const_iterator iter = v.begin(),
932 iter != iEnd; ++iter) {
934 std::vector<uint32_t>
const& seedVector = iter->getSeed();
937 std::vector<uint32_t>
const& stateVector = iter->getState();
940 outFile <<
"<ModuleLabel>\n" << iter->getLabel() <<
"\n</ModuleLabel>\n";
942 outFile <<
"<SeedLength>\n" << seedVectorLength <<
"\n</SeedLength>\n" ;
943 outFile <<
"<InitialSeeds>\n";
945 outFile <<
"</InitialSeeds>\n";
946 outFile <<
"<FullStateLength>\n" << stateVectorLength <<
"\n</FullStateLength>\n";
947 outFile <<
"<FullState>\n";
949 outFile <<
"</FullState>\n";
956 if(v.empty())
return;
957 size_t numItems = v.size();
958 for(
size_t i = 0;
i < numItems; ++
i) {
959 if(
i != 0 &&
i % 10 == 0) outFile <<
"\n";
960 outFile << std::setw(13) << v[
i];
967 std::string
fullName(getcwd(directory,
sizeof(directory)) ? directory :
"/PathIsTooBig");
974 std::string whichStates(
"<Event>");
980 std::string whichStates(
"<Lumi>");
987 std::vector<RandomEngineState>& cache,
988 std::string
const& whichStates) {
989 std::ifstream inFile;
993 <<
"Unable to open the file \""
994 << fileName <<
"\" to restore the random engine states.\n";
999 if(!inFile.good() || text != std::string(
"<RandomEngineStates>")) {
1001 <<
"Attempting to read file with random number engine states.\n"
1003 <<
"\" is ill-structured or otherwise corrupted.\n"
1004 <<
"Cannot read the file header word.\n";
1006 bool saveToCache =
false;
1011 std::vector<RandomEngineState>& cache,
1012 std::string
const& whichStates,
1013 bool& saveToCache) {
1014 std::string leading;
1015 std::string trailing;
1016 std::string moduleLabel;
1018 std::vector<uint32_t> seedVector;
1020 std::vector<uint32_t> stateVector;
1030 <<
"\" is ill-structured or otherwise corrupted.\n"
1031 <<
"Cannot read next field and did not hit the end yet.\n";
1035 if(leading == std::string(
"</RandomEngineStates>"))
return false;
1038 if(leading == std::string(
"</Event>") ||
1039 leading == std::string(
"</Lumi>")) {
1040 saveToCache =
false;
1045 if(leading == std::string(
"<Event>") ||
1046 leading == std::string(
"<Lumi>")) {
1047 saveToCache = (leading == whichStates);
1053 is >> moduleLabel >> trailing;
1055 leading != std::string(
"<ModuleLabel>") ||
1056 trailing != std::string(
"</ModuleLabel>")) {
1059 <<
"\" is ill-structured or otherwise corrupted.\n"
1060 <<
"Cannot read a module label when restoring random engine states.\n";
1063 is >> leading >> seedVectorSize >> trailing;
1065 leading != std::string(
"<SeedLength>") ||
1066 trailing != std::string(
"</SeedLength>")) {
1069 <<
"\" is ill-structured or otherwise corrupted.\n"
1070 <<
"Cannot read seed vector length when restoring random engine states.\n";
1075 leading != std::string(
"<InitialSeeds>")) {
1078 <<
"\" is ill-structured or otherwise corrupted.\n"
1079 <<
"Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1085 <<
"\" is ill-structured or otherwise corrupted.\n"
1086 <<
"The number of seeds exceeds 64K.\n";
1093 trailing != std::string(
"</InitialSeeds>")) {
1096 <<
"\" is ill-structured or otherwise corrupted.\n"
1097 <<
"Cannot read end of InitialSeeds when restoring random engine states.\n";
1100 is >> leading >> stateVectorSize >> trailing;
1102 leading != std::string(
"<FullStateLength>") ||
1103 trailing != std::string(
"</FullStateLength>")) {
1106 <<
"\" is ill-structured or otherwise corrupted.\n"
1107 <<
"Cannot read state vector length when restoring random engine states.\n";
1112 leading != std::string(
"<FullState>")) {
1115 <<
"\" is ill-structured or otherwise corrupted.\n"
1116 <<
"Cannot read beginning of FullState when restoring random engine states.\n";
1122 <<
"\" is ill-structured or otherwise corrupted.\n"
1123 <<
"The number of states exceeds 64K.\n";
1126 readVector(is, stateVectorSize, stateVector);
1130 trailing != std::string(
"</FullState>")) {
1133 <<
"\" is ill-structured or otherwise corrupted.\n"
1134 <<
"Cannot read end of FullState when restoring random engine states.\n";
1139 randomEngineState.
setLabel(moduleLabel);
1140 std::vector<RandomEngineState>::iterator
state =
1141 std::lower_bound(cache.begin(), cache.end(), randomEngineState);
1143 if(state != cache.end() && moduleLabel == state->getLabel()) {
1144 if(seedVector.size() != state->getSeed().size() ||
1145 stateVector.size() != state->getState().size()) {
1148 <<
"\" is ill-structured or otherwise corrupted.\n"
1149 <<
"Vectors containing engine state are the incorrect size for the type of random engine.\n";
1151 state->setSeed(seedVector);
1152 state->setState(stateVector);
1161 v.reserve(numItems);
1163 for(
unsigned i = 0;
i < numItems; ++
i) {
1168 <<
"\" is ill-structured or otherwise corrupted.\n"
1169 <<
"Cannot read vector when restoring random engine states.\n";
1180 for(EngineMap::const_iterator iter =
engineMap_.begin();
1187 std::string
const& moduleLabel = iter->first;
1191 if(engineName == std::string(
"RanecuEngine")) {
1192 assert(seeds.size() == 2U);
1195 offset1 = offset1 %
mod;
1196 offset2 = offset2 %
mod;
1197 seeds[0] = (seeds[0] + offset1) % mod;
1198 seeds[0] = (seeds[0] + offset2) % mod;
1200 seedL[0] =
static_cast<long int>(seeds[0]);
1201 seedL[1] =
static_cast<long int>(seeds[1]);
1202 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);
1217 assert(engineName ==
"TRandom3");
1222 if((max32 - seeds[0]) >= offset1) {
1223 seeds[0] = seeds[0] + offset1;
1225 seeds[0] = offset1 - (max32 - seeds[0]) - 1U;
1227 if((max32 - seeds[0]) >= offset2) {
1228 seeds[0] = seeds[0] + offset2;
1230 seeds[0] = offset2 - (max32 - seeds[0]) - 1U;
1232 long seedL =
static_cast<long>(seeds[0]);
1241 uint32_t seedu32 =
static_cast<uint32_t
>(seedL);
1242 assert(seeds[0] == seedu32);
1244 iter->second->setSeed(seedL, 0);
1253 for(VString::const_iterator it = pSets.begin(), itEnd = pSets.end(); it != itEnd; ++it) {
1254 if(*it != std::string(
"moduleSeeds")) {
1256 <<
"RandomNumberGeneratorService supports two configuration interfaces.\n"
1257 <<
"One is old and deprecated, but still supported for backward compatibility\n"
1258 <<
"reasons. It is illegal to mix parameters using both the old and new service\n"
1259 <<
"interface in the same configuration. It is assumed the old interface is being\n"
1260 <<
"used if the parameter set named \"moduleSeeds\" exists. In that case it is\n"
1261 <<
"illegal to have any other nested ParameterSets. This exception was thrown\n"
1262 <<
"because that happened.\n";
1268 std::vector<uint32_t> seeds;
1271 for(VString::const_iterator itName = names.begin(), itNameEnd = names.end();
1272 itName != itNameEnd; ++itName) {
1277 seeds.push_back(seed);
1283 <<
"The CLHEP::HepJamesRandom engine seed should be in the range 0 to 900000000.\n"
1284 <<
"The seed passed to the RandomNumberGenerationService from the\n"
1285 "configuration file was " << seed <<
". This was for the module\n"
1286 <<
"with label \"" << *itName <<
"\".";
1288 long seedL =
static_cast<long>(seed);
1289 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)
static size_t const maxStates
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)
edm::InputTag restoreStateTag_
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.
static size_t const maxSeeds
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)
list mod
Load physics model.
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
edm::InputTag restoreStateBeginLumiTag_
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()
char data[epos_bytes_allocation]
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)
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_