CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RandomNumberGeneratorService.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RandomEngine
4 // Class : RandomNumberGeneratorService
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones, W. David Dagenhart
10 // Created: Tue Mar 7 09:43:46 EST 2006 (originally in FWCore/Services)
11 //
12 
14 
22 #include "CLHEP/Random/JamesRandom.h"
23 #include "CLHEP/Random/RanecuEngine.h"
24 #include "CLHEP/Random/engineIDulong.h"
29 
33 
34 #include <iostream>
35 #include <fstream>
36 #include <limits>
37 #include <unistd.h>
38 #include <sstream>
39 
40 namespace edm {
41  namespace service {
42 
43  uint32_t RandomNumberGeneratorService::maxSeedRanecu = 2147483647U;
45  uint32_t RandomNumberGeneratorService::maxSeedTRandom3 = 4294967295U;
46 
48  ActivityRegistry& activityRegistry):
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")),
54  firstLumi_(true),
55  childIndex_(0U),
56  eventSeedOffset_(pset.getUntrackedParameter<unsigned>("eventSeedOffset")),
57  failedToFindStatesInLumi_(false) {
58 
59  if (!restoreFileName_.empty() && !restoreStateLabel_.empty()) {
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";
65  }
66 
67  // The saveFileName and must correspond to a file name without any path specification.
68  // Throw if that is not true.
69  if (!saveFileName_.empty() && (saveFileName_.find("/") != std::string::npos)) {
71  << "The saveFileName parameter must be a simple file name with no path\n"
72  << "specification. In the configuration, it was given the value \""
73  << saveFileName_ << "\"\n";
74  }
75 
76  // Check if the configuration file is still expressed in the old style.
77  // We do this by looking for a PSet named moduleSeeds. This parameter
78  // is unique to an old style cfg file.
79  if (pset.exists("moduleSeeds")) {
80  oldStyleConfig(pset);
81  }
82  else {
83 
84  uint32_t initialSeed;
85  VUint32 initialSeedSet;
86  std::string engineName;
87 
89  for (VString::const_iterator it = pSets.begin(), itEnd = pSets.end(); it != itEnd; ++it) {
90 
91  ParameterSet const& modulePSet = pset.getParameterSet(*it);
92  engineName = modulePSet.getUntrackedParameter<std::string>("engineName", std::string("HepJamesRandom"));
93 
94  bool initialSeedExists = modulePSet.exists("initialSeed");
95  bool initialSeedSetExists = modulePSet.exists("initialSeedSet");
96 
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";
103  }
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"
109  << "the other.\n";
110  }
111  else if (initialSeedExists) {
112  initialSeed = modulePSet.getUntrackedParameter<uint32_t>("initialSeed");
113  initialSeedSet.clear();
114  initialSeedSet.push_back(initialSeed);
115  }
116  else if (initialSeedSetExists) {
117  initialSeedSet = modulePSet.getUntrackedParameter<VUint32>("initialSeedSet");
118  }
119  seedMap_[*it] = initialSeedSet;
120  engineNameMap_[*it] = engineName;
121 
122  // For the CLHEP::RanecuEngine case, require a seed set containing exactly two seeds.
123 
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" ;
131  }
132  boost::shared_ptr<CLHEP::HepRandomEngine> engine(new CLHEP::RanecuEngine());
133  engineMap_[*it] = engine;
134 
135  if (initialSeedSet[0] > maxSeedRanecu ||
136  initialSeedSet[1] > maxSeedRanecu) { // They need to fit in a 31 bit integer
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";
142  }
143  long int seedL[2];
144  seedL[0] = static_cast<long int>(initialSeedSet[0]);
145  seedL[1] = static_cast<long int>(initialSeedSet[1]);
146  engine->setSeeds(seedL,0);
147  }
148  // For the other engines, one seed is required
149  else {
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" ;
156  }
157  long int seedL = static_cast<long int>(initialSeedSet[0]);
158 
159  if (engineName == "HepJamesRandom") {
160  if (initialSeedSet[0] > maxSeedHepJames) {
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";
166  }
167  boost::shared_ptr<CLHEP::HepRandomEngine> engine(new CLHEP::HepJamesRandom(seedL));
168  engineMap_[*it] = engine;
169  }
170  else if(engineName == "TRandom3") {
171 
172  // There is a dangerous conversion from uint32_t to long
173  // that occurs above. In the next 2 lines we check the
174  // behavior is what we need for the service to work
175  // properly. This conversion is forced on us by the
176  // CLHEP and ROOT interfaces. If the assert ever starts
177  // to fail we will have to come up with a way to deal
178  // with this.
179  uint32_t seedu32 = static_cast<uint32_t>(seedL);
180  assert(initialSeedSet[0] == seedu32);
181 
182  boost::shared_ptr<CLHEP::HepRandomEngine> engine(new TRandomAdaptor(seedL));
183  engineMap_[*it] = engine;
184  }
185  else {
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 << "\"";
190  }
191  }
192  }
193  }
194 
196 
199 
202 
205 
208 
211 
214 
217 
220 
222 
223  // the default for the stack is to point to the 'end' of our map which is used to define not set
224  engineStack_.push_back(engineMap_.end());
225  currentEngine_ = engineMap_.end();
226 
227  labelStack_.push_back(std::string());
228  currentLabel_ = std::string();
229  }
230 
232  }
233 
234  CLHEP::HepRandomEngine&
236 
237  if (currentEngine_ == engineMap_.end()) {
238  if (currentLabel_ != std::string() ) {
240  << "The module with label \""
241  << currentLabel_
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"
247  " " << currentLabel_ << " = cms.PSet(\n"
248  " initialSeed = cms.untracked.uint32(your_seed),\n"
249  " engineName = cms.untracked.string('TRandom3')\n"
250  " )\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";
253  }
254  else {
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";
261  }
262  }
263  return *(currentEngine_->second);
264  }
265 
266  uint32_t
268 
269  std::map<std::string, VUint32>::const_iterator iter;
270  iter = seedMap_.find(currentLabel_);
271 
272  if (iter == seedMap_.end()) {
273  if (currentLabel_ != std::string() ) {
275  << "The module with label \""
276  << currentLabel_
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"
282  " " << currentLabel_ << " = cms.PSet(\n"
283  " initialSeed = cms.untracked.uint32(your_seed),\n"
284  " engineName = cms.untracked.string('TRandom3')\n"
285  " )\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";
288  }
289  else {
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";
296  }
297  }
298  return iter->second[0];
299  }
300 
301  void
304 
305  std::string emptyString;
306  desc.addUntracked<std::string>("restoreStateLabel", emptyString);
307  desc.addUntracked<std::string>("saveFileName", emptyString);
308  desc.addUntracked<std::string>("restoreFileName", emptyString);
309  desc.addUntracked<bool>("enableChecking", false);
310  desc.addUntracked<unsigned>("eventSeedOffset", 0U);
311 
313  // When the migration away from the deprecated interface is complete it would be better
314  // to change the next line to a declaration of a single parameter named initialSeed instead
315  // of being a wildcard. Also the next two lines might also be combined with an "exclusive or"
316  // operator.
317  val.addWildcardUntracked<uint32_t>("*")->setComment("In the new interface, this wildcard will "
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");
323 
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");
327  desc.addNode(wnode);
328 
329  // This only exists for backward compatibility reasons
330  // This should be removed if all the configurations are
331  // ever upgraded properly.
332  desc.addOptionalUntracked<uint32_t>("sourceSeed")->
333  setComment("This parameter is deprecated, has no effect and will likely be completely removed someday");
334 
335  descriptions.add("RandomNumberGeneratorService", desc);
336  }
337 
338  void
339  RandomNumberGeneratorService::postForkReacquireResources(unsigned childIndex, unsigned kMaxChildren) {
340  childIndex_ = childIndex;
341 
342  std::ostringstream suffix;
343  suffix << "_" << childIndex;
344  saveFileName_ += suffix.str();
345  }
346 
347  // The next three functions contain the complex logic
348  // such that things occur in the proper sequence to be
349  // able to save and restore the states.
350 
351  void
353 
354  if (firstLumi_) {
355  // copy state from engines to lumi cache
357 
358  if (!restoreFileName_.empty()) {
359  // copy state from text file to lumi cache
361  }
362  }
363  else {
365  }
366 
367  // copy state from LuminosityBlock to lumi cache
368  if (!restoreStateLabel_.empty()) {
370  }
371 
372  if (!firstLumi_ || !restoreFileName_.empty() || !restoreStateLabel_.empty()) {
373  // copy state from lumi cache to engines
375  }
376  }
377 
378  // During the beginLumi processing the producer will copy the
379  // the lumi cache to a product if the producer was scheduled
380  // in a path in the configuration
381 
382  void
384 
385  if (firstLumi_) {
386  // reset state with new seeds based on child index
388  if (!restoreFileName_.empty()) {
390  // copy state from text file to event cache
392  }
393  }
394  if (!firstLumi_ || !restoreFileName_.empty()) {
395  // copy state from event cache to engines
397  }
398  firstLumi_ = false;
399  }
400 
401  void
403  // copy from Event to event cache
404  if (!restoreStateLabel_.empty()) {
406  readFromEvent(event);
407 
408  // copy from event cache to engines
410  }
411  else {
412  // copy from engines to event cache
414  }
415  // if requested write text file from both caches
416  if (!saveFileName_.empty()) {
418  if (!saveFileNameRecorded_) {
419  std::string fullName = constructSaveFileName();
420  Service<JobReport> reportSvc;
421  reportSvc->reportRandomStateFile(fullName);
422  saveFileNameRecorded_ = true;
423  }
424  }
425  }
426 
427  // During the event processing the producer will copy the
428  // the event cache to a product if the producer was scheduled
429  // in a path in the configuration
430 
431  void
433  {
434  push(description.moduleLabel());
435  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
436  engineStateStack_.push_back(currentEngine_->second->put());
437  }
438  }
439 
440  void
442  {
443  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
444  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
451  }
452  engineStateStack_.pop_back();
453  }
454  pop();
455  }
456 
457  void
459  push(description.moduleLabel());
460  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
461  engineStateStack_.push_back(currentEngine_->second->put());
462  }
463  }
464 
465  void
467  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
468  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
475  }
476  engineStateStack_.pop_back();
477  }
478  pop();
479  }
480 
481  void
483  push(description.moduleLabel());
484  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
485  engineStateStack_.push_back(currentEngine_->second->put());
486  }
487  }
488 
489  void
491  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
492  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
499  }
500  engineStateStack_.pop_back();
501  }
502  pop();
503  }
504 
505  void
507  push(description.moduleLabel());
508  }
509 
510  void
512  pop();
513  }
514 
515  void
517  push(description.moduleLabel());
518  }
519 
520  void
522  pop();
523  }
524 
525  void
527  push(description.moduleLabel());
528  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
529  engineStateStack_.push_back(currentEngine_->second->put());
530  }
531  }
532 
533  void
535  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
536  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
543  }
544  engineStateStack_.pop_back();
545  }
546  pop();
547  }
548 
549  void
551  push(description.moduleLabel());
552  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
553  engineStateStack_.push_back(currentEngine_->second->put());
554  }
555  }
556 
557  void
559  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
560  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
567  }
568  engineStateStack_.pop_back();
569  }
570  pop();
571  }
572 
573  void
575  push(description.moduleLabel());
576  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
577  engineStateStack_.push_back(currentEngine_->second->put());
578  }
579  }
580 
581  void
583  if (enableChecking_ && currentEngine_ != engineMap_.end()) {
584  if (engineStateStack_.back() != currentEngine_->second->put()) {
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";
591  }
592  engineStateStack_.pop_back();
593  }
594  pop();
595  }
596 
597  std::vector<RandomEngineState> const&
599  return lumiCache_;
600  }
601 
602  std::vector<RandomEngineState> const&
604  return eventCache_;
605  }
606 
607  void
609  std::cout << "\n\nRandomNumberGeneratorService dump\n\n";
610 
611  std::cout << " Contents of seedMap\n";
612  for (std::map<std::string, std::vector<uint32_t> >::const_iterator iter = seedMap_.begin();
613  iter != seedMap_.end();
614  ++iter) {
615  std::cout << " " << iter->first;
616  std::vector<uint32_t> seeds = iter->second;
617  for (std::vector<uint32_t>::const_iterator vIter = seeds.begin();
618  vIter != seeds.end();
619  ++vIter) {
620  std::cout << " " << *vIter;
621  }
622  std::cout << "\n";
623  }
624  std::cout << "\n Contents of engineNameMap\n";
625  for (std::map<std::string, std::string>::const_iterator iter = engineNameMap_.begin();
626  iter != engineNameMap_.end();
627  ++iter) {
628  std::cout << " " << iter->first << " " << iter->second << "\n";
629  }
630  std::cout << "\n Contents of engineMap\n";
631  for (EngineMap::const_iterator iter = engineMap_.begin();
632  iter != engineMap_.end();
633  ++iter) {
634  std::cout << " " << iter->first
635  << " " << iter->second->name() << " ";
636  if (iter->second->name() == std::string("HepJamesRandom")) {
637  std::cout << iter->second->getSeed();
638  }
639  else {
640  std::cout << "Engine does not know original seed";
641  }
642  std::cout << "\n";
643  }
644  std::cout << "\n";
645  std::cout << " currentLabel_ = " << currentLabel_ << "\n";
646  std::cout << " labelStack_ size = " << labelStack_.size() << "\n";
647  int i = 0;
648  for (VString::const_iterator iter = labelStack_.begin();
649  iter != labelStack_.end();
650  ++iter, ++i) {
651  std::cout << " " << i << " " << *iter << "\n";
652  }
653  if (currentEngine_ == engineMap_.end()) {
654  std::cout << " currentEngine points to end\n";
655  }
656  else {
657  std::cout << " currentEngine_ = " << currentEngine_->first
658  << " " << currentEngine_->second->name()
659  << " " << currentEngine_->second->getSeed() << "\n";
660  }
661 
662  std::cout << " engineStack_ size = " << engineStack_.size() << "\n";
663  i = 0;
664  for (std::vector<EngineMap::const_iterator>::const_iterator iter = engineStack_.begin();
665  iter != engineStack_.end();
666  ++iter, ++i) {
667  if (*iter == engineMap_.end()) {
668  std::cout << " " << i << " Points to end of engine map\n";
669  }
670  else {
671  std::cout << " " << i << " " << (*iter)->first
672  << " " << (*iter)->second->name() << " " << (*iter)->second->getSeed() << "\n";
673  }
674  }
675 
676  std::cout << " restoreStateLabel_ = " << restoreStateLabel_ << "\n";
677  std::cout << " saveFileName_ = " << saveFileName_ << "\n";
678  std::cout << " restoreFileName_ = " << restoreFileName_ << "\n";
679  }
680 
681  void
682  RandomNumberGeneratorService::push(std::string const& iLabel)
683  {
684  currentEngine_ = engineMap_.find(iLabel);
685  engineStack_.push_back(currentEngine_);
686 
687  labelStack_.push_back(iLabel);
688  currentLabel_ = iLabel;
689  }
690 
691  void
693  {
694  engineStack_.pop_back();
695  //NOTE: algorithm is such that we always have at least one item in the stacks
696  currentEngine_ = engineStack_.back();
697  labelStack_.pop_back();
698  currentLabel_ = labelStack_.back();
699  }
700 
701  void
703 
705 
706  lumi.getByLabel(restoreStateLabel_, "beginLumi", states);
707 
708  if (!states.isValid()) {
710  return;
711  }
713  states->getRandomEngineStates(lumiCache_);
714  }
715 
716  void
718 
720 
721  event.getByLabel(restoreStateLabel_, states);
722 
723  if (!states.isValid()) {
725  return;
726  }
727  else {
729  << "The RandomNumberGeneratorService is trying to restore\n"
730  << "the state of the random engines by reading a product from\n"
731  << "the Event with label \"" << restoreStateLabel_ << "\". It\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";
737  }
738  }
741  << "The RandomNumberGeneratorService is trying to restore\n"
742  << "the state of the random engines by reading a product from\n"
743  << "the Event and LuminosityBlock with label \"" << restoreStateLabel_ << "\".\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";
747  }
748  states->getRandomEngineStates(eventCache_);
749  }
750 
751  bool
753 
755 
756  event.getByLabel(restoreStateLabel_, states);
757  if (!states.isValid()) {
758  return false;
759  }
760  for (std::vector<RandomEngineState>::const_iterator state = states->begin(),
761  iEnd = states->end();
762  state != iEnd; ++state) {
763 
764  std::vector<RandomEngineState>::iterator cachedState =
765  std::lower_bound(eventCache_.begin(), eventCache_.end(), *state);
766 
767 
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";
778  }
779  cachedState->setSeed(state->getSeed());
780  cachedState->setState(state->getState());
781  }
782  }
783  return true;
784  }
785 
786  void
787  RandomNumberGeneratorService::snapShot(std::vector<RandomEngineState> & cache)
788  {
789  cache.resize(engineMap_.size());
790  std::vector<RandomEngineState>::iterator state = cache.begin();
791 
792  for (EngineMap::const_iterator iter = engineMap_.begin();
793  iter != engineMap_.end();
794  ++iter, ++state) {
795 
796  state->setLabel(iter->first);
797  state->setSeed(seedMap_[iter->first]);
798 
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();
804  ++vIter) {
805  state->push_back_stateVector(static_cast<uint32_t>(*vIter));
806  }
807  }
808  }
809 
810  void
811  RandomNumberGeneratorService::restoreFromCache(std::vector<RandomEngineState> const& cache) {
812  for (std::vector<RandomEngineState>::const_iterator iter = cache.begin(),
813  iEnd = cache.end();
814  iter != iEnd; ++iter) {
815 
816  std::string const& engineLabel = iter->getLabel();
817 
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));
824  }
825 
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();
830  iVal != theEnd;
831  ++iVal) {
832  long seedL = static_cast<long>(*iVal);
833  engineSeedsL.push_back(seedL);
834 
835  // There is a dangerous conversion from uint32_t to long
836  // that occurs above. In the next 2 lines we check the
837  // behavior is what we need for the service to work
838  // properly. This conversion is forced on us by the
839  // CLHEP and ROOT interfaces. If the assert ever starts
840  // to fail we will have to come up with a way to deal
841  // with this.
842  uint32_t seedu32 = static_cast<uint32_t>(seedL);
843  assert(*iVal == seedu32);
844  }
845 
846  EngineMap::iterator engine = engineMap_.find(engineLabel);
847 
848  if (engine != engineMap_.end()) {
849 
850  seedMap_[engineLabel] = engineSeeds;
851 
852  // We need to handle each type of engine differently because each
853  // has different requirements on the seed or seeds.
854  if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::HepJamesRandom>()) {
855 
856  checkEngineType(engine->second->name(), std::string("HepJamesRandom"), engineLabel);
857 
858  // These two lines actually restore the seed and engine state.
859  engine->second->setSeed(engineSeedsL[0], 0);
860  engine->second->get(engineStateL);
861  }
862  else if (engineStateL[0] == CLHEP::engineIDulong<CLHEP::RanecuEngine>()) {
863 
864  checkEngineType(engine->second->name(), std::string("RanecuEngine"), engineLabel);
865 
866  // This line actually restores the engine state.
867  engine->second->get(engineStateL);
868  }
869  else if (engineStateL[0] == CLHEP::engineIDulong<TRandomAdaptor>()) {
870 
871  checkEngineType(engine->second->name(), std::string("TRandom3"), engineLabel);
872 
873  // This line actually restores the engine state.
874  engine->second->setSeed(engineSeedsL[0], 0);
875  engine->second->get(engineStateL);
876  }
877  // This should not be possible because this code should be able to restore
878  // any kind of engine whose state can be saved.
879  else {
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";
888  }
889  }
890  }
891  }
892 
893  void
894  RandomNumberGeneratorService::checkEngineType(std::string const& typeFromConfig,
895  std::string const& typeFromEvent,
896  std::string const& engineLabel)
897  {
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";
912  }
913  }
914 
915  void
917  {
918  std::ofstream outFile;
919  outFile.open(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
920  if (!outFile) {
922  << "Unable to open the file \""
923  << fileName << "\" to save the state of the random engines.\n";
924  }
925  outFile << "<RandomEngineStates>\n";
926 
927  outFile << "<Event>\n";
928  writeStates(eventCache_, outFile);
929  outFile << "</Event>\n" ;
930 
931  outFile << "<Lumi>\n";
932  writeStates(lumiCache_, outFile);
933  outFile << "</Lumi>\n" ;
934 
935  outFile << "</RandomEngineStates>\n" ;
936  }
937 
938  void
939  RandomNumberGeneratorService::writeStates(std::vector<RandomEngineState> const& v,
940  std::ofstream & outFile) {
941  for (std::vector<RandomEngineState>::const_iterator iter = v.begin(),
942  iEnd = v.end();
943  iter != iEnd; ++iter) {
944 
945  std::vector<uint32_t> const& seedVector = iter->getSeed();
946  std::vector<uint32_t>::size_type seedVectorLength = seedVector.size();
947 
948  std::vector<uint32_t> const& stateVector = iter->getState();
949  std::vector<uint32_t>::size_type stateVectorLength = stateVector.size();
950 
951  outFile << "<ModuleLabel>\n" << iter->getLabel() << "\n</ModuleLabel>\n";
952 
953  outFile << "<SeedLength>\n" << seedVectorLength << "\n</SeedLength>\n" ;
954  outFile << "<InitialSeeds>\n";
955  writeVector(seedVector, outFile);
956  outFile << "</InitialSeeds>\n";
957  outFile << "<FullStateLength>\n" << stateVectorLength << "\n</FullStateLength>\n";
958  outFile << "<FullState>\n";
959  writeVector(stateVector, outFile);
960  outFile << "</FullState>\n";
961  }
962  }
963 
964  void
966  std::ofstream & outFile)
967  {
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];
973  }
974  outFile << "\n";
975  }
976 
978  {
979  char directory[1500];
980  std::string fullName(getcwd(directory, sizeof(directory)) ? directory : "/PathIsTooBig");
981  fullName += "/" + saveFileName_;
982  return fullName;
983  }
984 
985  void
987  std::string whichStates("<Event>");
988  readStatesFromFile(fileName, eventCache_, whichStates);
989  }
990 
991  void
993  std::string whichStates("<Lumi>");
994  readStatesFromFile(fileName, lumiCache_, whichStates);
995  }
996 
997 
998  void
1000  std::vector<RandomEngineState> & cache,
1001  std::string const& whichStates) {
1002  std::ifstream inFile;
1003  inFile.open(fileName.c_str(), std::ifstream::in);
1004  if (!inFile) {
1006  << "Unable to open the file \""
1007  << fileName << "\" to restore the random engine states.\n";
1008  }
1009 
1010  std::string text;
1011  inFile >> text;
1012  if (!inFile.good() || text != std::string("<RandomEngineStates>")) {
1014  << "Attempting to read file with random number engine states.\n"
1015  << "File \"" << restoreFileName_
1016  << "\" is ill-structured or otherwise corrupted.\n"
1017  << "Cannot read the file header word.\n";
1018  }
1019  bool saveToCache = false;
1020  while (readEngineState(inFile, cache, whichStates, saveToCache)) { }
1021  }
1022 
1024  std::vector<RandomEngineState> & cache,
1025  std::string const& whichStates,
1026  bool & saveToCache) {
1027  std::string leading;
1028  std::string trailing;
1029  std::string moduleLabel;
1030  std::vector<uint32_t>::size_type seedVectorSize;
1031  std::vector<uint32_t> seedVector;
1032  std::vector<uint32_t>::size_type stateVectorSize;
1033  std::vector<uint32_t> stateVector;
1034 
1035  // First we need to look for the special strings
1036  // that mark the end of the file and beginning and
1037  // and end of the data for different sections.
1038 
1039  is >> leading;
1040  if (!is.good()) {
1042  << "File \"" << restoreFileName_
1043  << "\" is ill-structured or otherwise corrupted.\n"
1044  << "Cannot read next field and did not hit the end yet.\n";
1045  }
1046 
1047  // This marks the end of the file. We are done.
1048  if (leading == std::string("</RandomEngineStates>")) return false;
1049 
1050  // This marks the end of a section of the data
1051  if (leading == std::string("</Event>") ||
1052  leading == std::string("</Lumi>")) {
1053  saveToCache = false;
1054  return true;
1055  }
1056 
1057  // This marks the beginning of a section
1058  if (leading == std::string("<Event>") ||
1059  leading == std::string("<Lumi>")) {
1060  saveToCache = (leading == whichStates);
1061  return true;
1062  }
1063 
1064  // Process the next engine state
1065 
1066  is >> moduleLabel >> trailing;
1067  if (!is.good() ||
1068  leading != std::string("<ModuleLabel>") ||
1069  trailing != std::string("</ModuleLabel>")) {
1071  << "File \"" << restoreFileName_
1072  << "\" is ill-structured or otherwise corrupted.\n"
1073  << "Cannot read a module label when restoring random engine states.\n";
1074  }
1075 
1076  is >> leading >> seedVectorSize >> trailing;
1077  if (!is.good() ||
1078  leading != std::string("<SeedLength>") ||
1079  trailing != std::string("</SeedLength>")) {
1081  << "File \"" << restoreFileName_
1082  << "\" is ill-structured or otherwise corrupted.\n"
1083  << "Cannot read seed vector length when restoring random engine states.\n";
1084  }
1085 
1086  is >> leading;
1087  if (!is.good() ||
1088  leading != std::string("<InitialSeeds>")) {
1090  << "File \"" << restoreFileName_
1091  << "\" is ill-structured or otherwise corrupted.\n"
1092  << "Cannot read beginning of InitialSeeds when restoring random engine states.\n";
1093  }
1094 
1095  readVector(is, seedVectorSize, seedVector);
1096 
1097  is >> trailing;
1098  if (!is.good() ||
1099  trailing != std::string("</InitialSeeds>")) {
1101  << "File \"" << restoreFileName_
1102  << "\" is ill-structured or otherwise corrupted.\n"
1103  << "Cannot read end of InitialSeeds when restoring random engine states.\n";
1104  }
1105 
1106  is >> leading >> stateVectorSize >> trailing;
1107  if (!is.good() ||
1108  leading != std::string("<FullStateLength>") ||
1109  trailing != std::string("</FullStateLength>")) {
1111  << "File \"" << restoreFileName_
1112  << "\" is ill-structured or otherwise corrupted.\n"
1113  << "Cannot read state vector length when restoring random engine states.\n";
1114  }
1115 
1116  is >> leading;
1117  if (!is.good() ||
1118  leading != std::string("<FullState>")) {
1120  << "File \"" << restoreFileName_
1121  << "\" is ill-structured or otherwise corrupted.\n"
1122  << "Cannot read beginning of FullState when restoring random engine states.\n";
1123  }
1124 
1125  readVector(is, stateVectorSize, stateVector);
1126 
1127  is >> trailing;
1128  if (!is.good() ||
1129  trailing != std::string("</FullState>")) {
1131  << "File \"" << restoreFileName_
1132  << "\" is ill-structured or otherwise corrupted.\n"
1133  << "Cannot read end of FullState when restoring random engine states.\n";
1134  }
1135 
1136  if (saveToCache) {
1137  RandomEngineState randomEngineState;
1138  randomEngineState.setLabel(moduleLabel);
1139  std::vector<RandomEngineState>::iterator state =
1140  std::lower_bound(cache.begin(), cache.end(), randomEngineState);
1141 
1142  if (state != cache.end() && moduleLabel == state->getLabel()) {
1143  if (seedVector.size() != state->getSeed().size() ||
1144  stateVector.size() != state->getState().size()) {
1146  << "File \"" << restoreFileName_
1147  << "\" is ill-structured or otherwise corrupted.\n"
1148  << "Vectors containing engine state are the incorrect size for the type of random engine.\n";
1149  }
1150  state->setSeed(seedVector);
1151  state->setState(stateVector);
1152  }
1153  }
1154  return true;
1155  }
1156 
1157  void
1158  RandomNumberGeneratorService::readVector(std::istream &is, unsigned numItems, std::vector<uint32_t> & v) {
1159  v.clear();
1160  v.reserve(numItems);
1161  uint32_t data;
1162  for (unsigned i = 0; i < numItems; ++i) {
1163  is >> data;
1164  if (!is.good()) {
1166  << "File \"" << restoreFileName_
1167  << "\" is ill-structured or otherwise corrupted.\n"
1168  << "Cannot read vector when restoring random engine states.\n";
1169  }
1170  v.push_back(data);
1171  }
1172  }
1173 
1174  void
1176 
1177  if (childIndex_ == 0U && eventSeedOffset_ == 0U) return;
1178 
1179  for (EngineMap::const_iterator iter = engineMap_.begin();
1180  iter != engineMap_.end();
1181  ++iter) {
1182 
1183  uint32_t offset1 = childIndex_;
1184  uint32_t offset2 = eventSeedOffset_;
1185 
1186  std::string const& moduleLabel = iter->first;
1187  std::string const& engineName = engineNameMap_[moduleLabel];
1188  VUint32 & seeds = seedMap_[moduleLabel];
1189 
1190  if (engineName == std::string("RanecuEngine")) {
1191  assert(seeds.size() == 2U);
1192  // Wrap around if the offsets push the seed over the maximum allowed value
1193  uint32_t mod = maxSeedRanecu + 1U;
1194  offset1 = offset1 % mod;
1195  offset2 = offset2 % mod;
1196  seeds[0] = (seeds[0] + offset1) % mod;
1197  seeds[0] = (seeds[0] + offset2) % mod;
1198  long int seedL[2];
1199  seedL[0] = static_cast<long int>(seeds[0]);
1200  seedL[1] = static_cast<long int>(seeds[1]);
1201  iter->second->setSeeds(seedL,0);
1202  }
1203  else {
1204  assert(seeds.size() == 1U);
1205 
1206  if (engineName == "HepJamesRandom") {
1207  // Wrap around if the offsets push the seed over the maximum allowed value
1208  uint32_t mod = maxSeedHepJames + 1U;
1209  offset1 = offset1 % mod;
1210  offset2 = offset2 % mod;
1211  seeds[0] = (seeds[0] + offset1) % mod;
1212  seeds[0] = (seeds[0] + offset2) % mod;
1213 
1214  long int seedL = static_cast<long int>(seeds[0]);
1215  iter->second->setSeed(seedL, 0);
1216  }
1217  else {
1218  assert(engineName == "TRandom3");
1219  // Wrap around if the offsets push the seed over the maximum allowed value
1220  // We have to be extra careful with this one because it may also go beyond
1221  // the values 32 bits can hold
1222  uint32_t max32 = maxSeedTRandom3;
1223  if ((max32 - seeds[0]) >= offset1) {
1224  seeds[0] = seeds[0] + offset1;
1225  }
1226  else {
1227  seeds[0] = offset1 - (max32 - seeds[0]) - 1U;
1228  }
1229  if ((max32 - seeds[0]) >= offset2) {
1230  seeds[0] = seeds[0] + offset2;
1231  }
1232  else {
1233  seeds[0] = offset2 - (max32 - seeds[0]) - 1U;
1234  }
1235  long seedL = static_cast<long>(seeds[0]);
1236 
1237  // There is a dangerous conversion from uint32_t to long
1238  // that occurs above. In the next 2 lines we check the
1239  // behavior is what we need for the service to work
1240  // properly. This conversion is forced on us by the
1241  // CLHEP and ROOT interfaces. If the assert ever starts
1242  // to fail we will have to come up with a way to deal
1243  // with this.
1244  uint32_t seedu32 = static_cast<uint32_t>(seedL);
1245  assert(seeds[0] == seedu32);
1246 
1247  iter->second->setSeed(seedL, 0);
1248  }
1249  }
1250  }
1251  }
1252 
1253  void
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";
1266  }
1267  }
1268 
1269  ParameterSet const& moduleSeeds = pset.getParameterSet("moduleSeeds");
1270 
1271  std::vector<uint32_t> seeds;
1272 
1273  VString names = moduleSeeds.getParameterNames();
1274  for (VString::const_iterator itName = names.begin(), itNameEnd = names.end();
1275  itName != itNameEnd; ++itName) {
1276 
1277  uint32_t seed = moduleSeeds.getUntrackedParameter<uint32_t>(*itName);
1278 
1279  seeds.clear();
1280  seeds.push_back(seed);
1281  seedMap_[*itName] = seeds;
1282  engineNameMap_[*itName] = std::string("HepJamesRandom");
1283 
1284  if (seed > maxSeedHepJames) {
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 << "\".";
1290  }
1291  long seedL = static_cast<long>(seed);
1292  engineMap_[*itName] = boost::shared_ptr<CLHEP::HepRandomEngine>(new CLHEP::HepJamesRandom(seedL));
1293  }
1294  }
1295  }
1296 }
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
int i
Definition: DBlmapReader.cc:9
void restoreFromCache(std::vector< RandomEngineState > const &cache)
void watchPostModuleBeginLumi(PostModuleBeginLumi::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void postModuleEndJob(ModuleDescription const &description)
void preModuleEndLumi(ModuleDescription const &description)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
tuple lumi
Definition: fjr2json.py:41
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 &parameterName) const
checks if a parameter exists
std::string const & moduleName() const
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
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)
uint16_t size_type
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void watchPreModule(PreModule::slot_type const &iSlot)
dictionary map
Definition: Association.py:160
void preModuleBeginLumi(ModuleDescription const &description)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:188
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)
tuple text
Definition: runonSM.py:42
void readStatesFromFile(std::string const &fileName, std::vector< RandomEngineState > &cache, std::string const &whichStates)
tuple pset
Definition: CrabTask.py:85
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
bool isValid() const
Definition: HandleBase.h:76
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
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
tuple out
Definition: dbtoconf.py:99
void preModuleEndRun(ModuleDescription const &description)
tuple description
Definition: idDealer.py:66
string fullName
ParameterSet const & getParameterSet(std::string const &) const
void postModuleBeginLumi(ModuleDescription const &description)
void preModuleEndJob(ModuleDescription const &description)
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)
char state
Definition: procUtils.cc:75
static std::string const emptyString("")
void watchPostForkReacquireResources(PostForkReacquireResources::slot_type const &iSlot)
void writeVector(VUint32 const &v, std::ofstream &outFile)
void watchPostModuleBeginJob(PostModuleBeginJob::slot_type const &iSlot)
tuple cout
Definition: gather_cfg.py:41
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)
Definition: ecalDccMap.h:4
static const HistoName names[]
void watchPostModuleEndJob(PostModuleEndJob::slot_type const &iSlot)
mathSSE::Vec4< T > v
void watchPreModuleBeginRun(PreModuleBeginRun::slot_type const &iSlot)
void watchPostModuleEndLumi(PostModuleEndLumi::slot_type const &iSlot)
const std::string * moduleLabel() const
Definition: HLTadd.h:40