CMS 3D CMS Logo

PileupRandomNumberGenerator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Mixing/Base
4 // Class : PileupRandomNumberGenerator
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Christopher Jones
10 // Created: Wed, 09 Nov 2022 17:53:24 GMT
11 //
12 
13 // system include files
14 
15 // user include files
22 
24 
25 #include "CLHEP/Random/RandomEngine.h"
26 
27 PileupRandomNumberGenerator::PileupRandomNumberGenerator(std::vector<std::string> const& iModuleLabels) : m_seed(0) {
28  for (auto const& name : iModuleLabels) {
29  m_modulesToEngines.emplace(name, std::unique_ptr<CLHEP::HepRandomEngine>{});
30  }
31 }
32 
33 CLHEP::HepRandomEngine& PileupRandomNumberGenerator::getEngine(edm::StreamID const&) {
35 }
36 
39 }
40 
41 std::unique_ptr<CLHEP::HepRandomEngine> PileupRandomNumberGenerator::cloneEngine(edm::LuminosityBlockIndex const&) {
42  auto& engine = m_modulesToEngines[findPresentModule()];
43  return edm::cloneEngine(*engine);
44 }
45 
46 void PileupRandomNumberGenerator::setSeed(uint32_t iSeed) { m_seed = iSeed; }
47 
48 void PileupRandomNumberGenerator::setEngine(CLHEP::HepRandomEngine const& iEngine) {
49  for (auto& v : m_modulesToEngines) {
50  v.second = edm::cloneEngine(iEngine);
51  }
52 }
53 
56 
58  std::vector<RandomEngineState> const& iStates) {}
59 void PileupRandomNumberGenerator::setEventCache(edm::StreamID, std::vector<RandomEngineState> const& iStates) {}
60 
61 std::vector<RandomEngineState> const& PileupRandomNumberGenerator::getEventCache(edm::StreamID const&) const {
62  static const std::vector<RandomEngineState> s_dummy;
63  return s_dummy;
64 }
65 std::vector<RandomEngineState> const& PileupRandomNumberGenerator::getLumiCache(edm::LuminosityBlockIndex const&) const {
66  static const std::vector<RandomEngineState> s_dummy;
67  return s_dummy;
68 }
69 
71 
72 void PileupRandomNumberGenerator::print(std::ostream& os) const {}
73 
76  if (mcc == nullptr) {
78  << "PileupRandomNumberGenerator::getEngine()\n"
79  "Requested a random number engine from the RandomNumberGeneratorService\n"
80  "from an unallowed transition. ModuleCallingContext is null\n";
81  }
82  return mcc->moduleDescription()->moduleLabel();
83 }
CLHEP::HepRandomEngine & getEngine(edm::StreamID const &) final
Use this engine in event methods.
static ModuleCallingContext const * getCurrentModuleOnThread()
std::unique_ptr< CLHEP::HepRandomEngine > cloneEngine(edm::LuminosityBlockIndex const &) final
void setEventCache(edm::StreamID, std::vector< RandomEngineState > const &iStates) final
ModuleDescription const * moduleDescription() const noexcept
void consumes(edm::ConsumesCollector &&iC) const final
std::unique_ptr< CLHEP::HepRandomEngine > cloneEngine(CLHEP::HepRandomEngine const &)
Definition: cloneEngine.cc:27
void print(std::ostream &os) const final
For debugging purposes only.
void setEngine(CLHEP::HepRandomEngine const &)
void setLumiCache(edm::LuminosityBlockIndex, std::vector< RandomEngineState > const &iStates) final
std::vector< RandomEngineState > const & getEventCache(edm::StreamID const &) const final
std::unordered_map< std::string, std::unique_ptr< CLHEP::HepRandomEngine > > m_modulesToEngines
void preBeginLumi(edm::LuminosityBlock const &lumi) final
const std::string & findPresentModule() const
std::vector< RandomEngineState > const & getLumiCache(edm::LuminosityBlockIndex const &) const final
std::string const & moduleLabel() const
PileupRandomNumberGenerator(std::vector< std::string > const &iModuleLabels)
void postEventRead(edm::Event const &event) final
Definition: event.py:1