File indexing completed on 2024-04-06 12:22:36
0001 #ifndef Mixing_Base_PileupRandomNumberGenerator_h
0002 #define Mixing_Base_PileupRandomNumberGenerator_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <memory>
0023 #include <unordered_map>
0024
0025
0026 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0027 #include "SimDataFormats/RandomEngine/interface/RandomEngineState.h"
0028 #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
0029
0030
0031
0032 class PileupRandomNumberGenerator : public edm::RandomNumberGenerator {
0033 public:
0034 PileupRandomNumberGenerator(std::vector<std::string> const& iModuleLabels);
0035
0036 void setSeed(uint32_t iSeed);
0037 void setEngine(CLHEP::HepRandomEngine const&);
0038
0039 CLHEP::HepRandomEngine& getEngine(edm::StreamID const&) final;
0040
0041 CLHEP::HepRandomEngine& getEngine(edm::LuminosityBlockIndex const&) final;
0042
0043 std::unique_ptr<CLHEP::HepRandomEngine> cloneEngine(edm::LuminosityBlockIndex const&) final;
0044
0045 std::uint32_t mySeed() const final { return m_seed; }
0046
0047 private:
0048 void preBeginLumi(edm::LuminosityBlock const& lumi) final;
0049 void postEventRead(edm::Event const& event) final;
0050
0051 void setLumiCache(edm::LuminosityBlockIndex, std::vector<RandomEngineState> const& iStates) final;
0052 void setEventCache(edm::StreamID, std::vector<RandomEngineState> const& iStates) final;
0053
0054 std::vector<RandomEngineState> const& getEventCache(edm::StreamID const&) const final;
0055 std::vector<RandomEngineState> const& getLumiCache(edm::LuminosityBlockIndex const&) const final;
0056
0057 void consumes(edm::ConsumesCollector&& iC) const final;
0058
0059
0060 void print(std::ostream& os) const final;
0061
0062 static std::unique_ptr<CLHEP::HepRandomEngine> cloneEngine(CLHEP::HepRandomEngine const& existingEngine);
0063
0064 const std::string& findPresentModule() const;
0065
0066 std::unordered_map<std::string, std::unique_ptr<CLHEP::HepRandomEngine>> m_modulesToEngines;
0067 uint32_t m_seed;
0068 };
0069
0070 #endif