File indexing completed on 2024-04-06 12:13:03
0001 #ifndef FWCore_Services_ExternalRandomNumberGeneratorService_h
0002 #define FWCore_Services_ExternalRandomNumberGeneratorService_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <cstdint>
0012 #include <iosfwd>
0013 #include <memory>
0014 #include <vector>
0015
0016 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0017
0018 namespace edm {
0019
0020 class ExternalRandomNumberGeneratorService : public RandomNumberGenerator {
0021 public:
0022 ExternalRandomNumberGeneratorService();
0023 ExternalRandomNumberGeneratorService(ExternalRandomNumberGeneratorService const&) = delete;
0024 ExternalRandomNumberGeneratorService const& operator=(ExternalRandomNumberGeneratorService const&) = delete;
0025
0026 void setState(std::vector<unsigned long> const&, long seed);
0027 std::vector<unsigned long> getState() const;
0028
0029 CLHEP::HepRandomEngine& getEngine(StreamID const&) final;
0030 CLHEP::HepRandomEngine& getEngine(LuminosityBlockIndex const&) final;
0031 std::unique_ptr<CLHEP::HepRandomEngine> cloneEngine(LuminosityBlockIndex const&) final;
0032 std::uint32_t mySeed() const final;
0033
0034
0035
0036
0037
0038
0039
0040 void preBeginLumi(LuminosityBlock const& lumi) final;
0041 void postEventRead(Event const& event) final;
0042
0043 void setLumiCache(LuminosityBlockIndex, std::vector<RandomEngineState> const& iStates) final;
0044 void setEventCache(StreamID, std::vector<RandomEngineState> const& iStates) final;
0045
0046 std::vector<RandomEngineState> const& getEventCache(StreamID const&) const final;
0047 std::vector<RandomEngineState> const& getLumiCache(LuminosityBlockIndex const&) const final;
0048
0049 void consumes(ConsumesCollector&& iC) const final;
0050
0051
0052 void print(std::ostream& os) const final;
0053
0054 private:
0055 std::unique_ptr<CLHEP::HepRandomEngine> createFromState(std::vector<unsigned long> const&, long seed) const;
0056
0057 std::unique_ptr<CLHEP::HepRandomEngine> engine_;
0058 };
0059 }
0060 #endif