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:
25 
26  void setState(std::vector<unsigned long> const&, long seed);
27  std::vector<unsigned long> getState() const;
28 
29  CLHEP::HepRandomEngine& getEngine(StreamID const&) final;
30  CLHEP::HepRandomEngine& getEngine(LuminosityBlockIndex const&) final;
31  std::unique_ptr<CLHEP::HepRandomEngine> cloneEngine(LuminosityBlockIndex const&) final;
32  std::uint32_t mySeed() const final;
33 
34  // The following functions should not be used by general users. They
35  // should only be called by Framework code designed to work with the
36  // service while it is saving the engine states or restoring them.
37  // The first two are called by the EventProcessor at special times.
38  // The next two are called by a dedicated producer module (RandomEngineStateProducer).
39 
40  void preBeginLumi(LuminosityBlock const& lumi) final;
41  void postEventRead(Event const& event) final;
42 
43  void setLumiCache(LuminosityBlockIndex, std::vector<RandomEngineState> const& iStates) final;
44  void setEventCache(StreamID, std::vector<RandomEngineState> const& iStates) final;
45 
46  std::vector<RandomEngineState> const& getEventCache(StreamID const&) const final;
47  std::vector<RandomEngineState> const& getLumiCache(LuminosityBlockIndex const&) const final;
48 
49  void consumes(ConsumesCollector&& iC) const final;
50 
52  void print(std::ostream& os) const final;
53 
54  private:
55  std::unique_ptr<CLHEP::HepRandomEngine> createFromState(std::vector<unsigned long> const&, long seed) const;
56 
57  std::unique_ptr<CLHEP::HepRandomEngine> engine_;
58  };
59 } // namespace edm
60 #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:57
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