CMS 3D CMS Logo

ExternalRandomNumberGeneratorService.h
Go to the documentation of this file.
1 #ifndef FWCore_Services_ExternalRandomNumberGeneratorService_h
2 #define FWCore_Services_ExternalRandomNumberGeneratorService_h
3 
11 #include <cstdint>
12 #include <iosfwd>
13 #include <memory>
14 #include <vector>
15 
17 
18 namespace edm {
19 
21  public:
23 
24  void setState(std::vector<unsigned long> const&, long seed);
25  std::vector<unsigned long> getState() const;
26 
27  CLHEP::HepRandomEngine& getEngine(StreamID const&) final;
28  CLHEP::HepRandomEngine& getEngine(LuminosityBlockIndex const&) final;
29  std::unique_ptr<CLHEP::HepRandomEngine> cloneEngine(LuminosityBlockIndex const&) final;
30  std::uint32_t mySeed() const final;
31 
32  // The following functions should not be used by general users. They
33  // should only be called by Framework code designed to work with the
34  // service while it is saving the engine states or restoring them.
35  // The first two are called by the EventProcessor at special times.
36  // The next two are called by a dedicated producer module (RandomEngineStateProducer).
37 
38  void preBeginLumi(LuminosityBlock const& lumi) final;
39  void postEventRead(Event const& event) final;
40 
41  void setLumiCache(LuminosityBlockIndex, std::vector<RandomEngineState> const& iStates) final;
42  void setEventCache(StreamID, std::vector<RandomEngineState> const& iStates) final;
43 
44  std::vector<RandomEngineState> const& getEventCache(StreamID const&) const final;
45  std::vector<RandomEngineState> const& getLumiCache(LuminosityBlockIndex const&) const final;
46 
47  void consumes(ConsumesCollector&& iC) const final;
48 
50  void print(std::ostream& os) const final;
51 
52  private:
55 
56  std::unique_ptr<CLHEP::HepRandomEngine> createFromState(std::vector<unsigned long> const&, long seed) const;
57 
58  std::unique_ptr<CLHEP::HepRandomEngine> engine_;
59  };
60 } // namespace edm
61 #endif
edm::StreamID
Definition: StreamID.h:30
edm::ExternalRandomNumberGeneratorService::createFromState
std::unique_ptr< CLHEP::HepRandomEngine > createFromState(std::vector< unsigned long > const &, long seed) const
Definition: ExternalRandomNumberGeneratorService.cc:46
edm::ExternalRandomNumberGeneratorService::getEventCache
std::vector< RandomEngineState > const & getEventCache(StreamID const &) const final
Definition: ExternalRandomNumberGeneratorService.cc:79
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::ExternalRandomNumberGeneratorService::cloneEngine
std::unique_ptr< CLHEP::HepRandomEngine > cloneEngine(LuminosityBlockIndex const &) final
Definition: ExternalRandomNumberGeneratorService.cc:39
edm
HLT enums.
Definition: AlignableModifier.h:19
RandomNumberGenerator.h
edm::ExternalRandomNumberGeneratorService::mySeed
std::uint32_t mySeed() const final
Definition: ExternalRandomNumberGeneratorService.cc:69
edm::ExternalRandomNumberGeneratorService::setEventCache
void setEventCache(StreamID, std::vector< RandomEngineState > const &iStates) final
Definition: ExternalRandomNumberGeneratorService.cc:77
edm::ExternalRandomNumberGeneratorService::getEngine
CLHEP::HepRandomEngine & getEngine(StreamID const &) final
Use this engine in event methods.
Definition: ExternalRandomNumberGeneratorService.cc:34
edm::RandomNumberGenerator
Definition: RandomNumberGenerator.h:147
fileCollector.seed
seed
Definition: fileCollector.py:127
edm::ExternalRandomNumberGeneratorService::setState
void setState(std::vector< unsigned long > const &, long seed)
Definition: ExternalRandomNumberGeneratorService.cc:24
edm::LuminosityBlockIndex
Definition: LuminosityBlockIndex.h:33
edm::ExternalRandomNumberGeneratorService::operator=
ExternalRandomNumberGeneratorService const & operator=(ExternalRandomNumberGeneratorService const &)=delete
edm::ExternalRandomNumberGeneratorService::postEventRead
void postEventRead(Event const &event) final
Definition: ExternalRandomNumberGeneratorService.cc:73
edm::ExternalRandomNumberGeneratorService::print
void print(std::ostream &os) const final
For debugging purposes only.
Definition: ExternalRandomNumberGeneratorService.cc:91
edm::ExternalRandomNumberGeneratorService::getLumiCache
std::vector< RandomEngineState > const & getLumiCache(LuminosityBlockIndex const &) const final
Definition: ExternalRandomNumberGeneratorService.cc:83
edm::ExternalRandomNumberGeneratorService::setLumiCache
void setLumiCache(LuminosityBlockIndex, std::vector< RandomEngineState > const &iStates) final
Definition: ExternalRandomNumberGeneratorService.cc:75
edm::ExternalRandomNumberGeneratorService::getState
std::vector< unsigned long > getState() const
Definition: ExternalRandomNumberGeneratorService.cc:32
edm::ExternalRandomNumberGeneratorService::consumes
void consumes(ConsumesCollector &&iC) const final
Definition: ExternalRandomNumberGeneratorService.cc:88
edm::ExternalRandomNumberGeneratorService::preBeginLumi
void preBeginLumi(LuminosityBlock const &lumi) final
Definition: ExternalRandomNumberGeneratorService.cc:71
edm::ExternalRandomNumberGeneratorService::engine_
std::unique_ptr< CLHEP::HepRandomEngine > engine_
Definition: ExternalRandomNumberGeneratorService.h:58
edm::ExternalRandomNumberGeneratorService::ExternalRandomNumberGeneratorService
ExternalRandomNumberGeneratorService()
Definition: ExternalRandomNumberGeneratorService.cc:22
event
Definition: event.py:1
edm::ExternalRandomNumberGeneratorService
Definition: ExternalRandomNumberGeneratorService.h:20
edm::Event
Definition: Event.h:73
lumi
Definition: LumiSectionData.h:20
edm::ConsumesCollector
Definition: ConsumesCollector.h:45