#include <RandomNumberGenerator.h>
Public Member Functions | |
virtual CLHEP::HepRandomEngine & | getEngine () const =0 |
Use this to get the random number engine, this is the only function most users should call. More... | |
virtual CLHEP::HepRandomEngine & | getEngine (StreamID const &) const |
virtual CLHEP::HepRandomEngine & | getEngine (LuminosityBlockIndex const &) const |
virtual std::vector < RandomEngineState > const & | getEventCache () const =0 |
virtual std::vector < RandomEngineState > const & | getLumiCache () const =0 |
virtual uint32_t | mySeed () const =0 |
Exists for backward compatibility. More... | |
virtual void | postEventRead (Event const &event)=0 |
virtual void | preBeginLumi (LuminosityBlock const &lumi)=0 |
virtual void | print ()=0 |
For debugging purposes only. More... | |
RandomNumberGenerator () | |
virtual | ~RandomNumberGenerator () |
Private Member Functions | |
RandomNumberGenerator const & | operator= (RandomNumberGenerator const &) |
RandomNumberGenerator (RandomNumberGenerator const &) | |
Description: Interface for obtaining random number engines.
Usage: This class is the abstract interface to a Service which provides access to the random number engines which are used generate random numbers. One accesses the service using the Service system.
edm::Service<edm::RandomNumberGenerator> rng; CLHEP::HepRandomEngine& engine = rng->getEngine();
The RandomNumberGenerator automatically knows what module is requesting an engine and will return the proper one for that module.
A source cannot use this service and sources should not generate random numbers.
Random numbers should only be generated in two functions of a module, the function used to process the Event and also the beginLuminosityBlock function. Random numbers should not be generated at any other time, not in the constructor, not at beginJob, not at beginRun ... Note that this restriction applies to generating the random numbers only, it is fine to get the reference to the engine and save it or a pointer to it at other times as long as it is not used to generate random numbers.
The service owns the engines and handles memory management for them.
The service does a lot of work behind the scene to allow one to replay specific events of a prior process. There are two different mechanisms.
First, if the parameter named "saveFileName" is set the state of the random engines will be written to a separate text file before each event is processed. This text file is overwritten at each event. If a job crashes while processing an event, then one can replay the processing of the event where the crash occurred and get the same random number sequences.
Second, when a separate Producer module is also included in a path the state of all the engines managed by this service can be saved to the both the Event and LuminosityBlock. Then in a later process, the RandomNumberGenerator is capable of restoring the state of the engines in order to be able to exactly replay the earlier process starting at any event without having to replay the entire process.
This service performs tasks so that the random sequences in multiprocess jobs are independent sequences with different seeds.
Two warnings.
There are more details explaining this service on a TWIKI page which can be accessed through a link on the Framework TWIKI page of the SWGuide.
Definition at line 108 of file RandomNumberGenerator.h.
|
inline |
Definition at line 112 of file RandomNumberGenerator.h.
|
virtual |
Definition at line 4 of file RandomNumberGenerator.cc.
|
private |
|
pure virtual |
Use this to get the random number engine, this is the only function most users should call.
Implemented in edm::service::RandomNumberGeneratorService.
Referenced by gen::AMPTHadronizer::AMPTHadronizer(), CaloHitResponse::analogSignalAmplitude(), BaseEvtVtxGenerator::BaseEvtVtxGenerator(), edm::BeamHaloProducer::BeamHaloProducer(), FFTJetVertexAdder::beginJob(), BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator(), ElectronEnergyCalibrator::calibrate(), CastorDigiProducer::CastorDigiProducer(), CSCDigiProducer::CSCDigiProducer(), edm::DataMixingSiStripMCDigiWorker::DataMixingSiStripMCDigiWorker(), DTDigitizer::DTDigitizer(), EcalElectronicsSim::EcalElectronicsSim(), EcalHitResponse::EcalHitResponse(), EcalTBMCInfoProducer::EcalTBMCInfoProducer(), ESElectronicsSim::encode(), ESDigitizer::ESDigitizer(), ESElectronicsSimFast::ESElectronicsSimFast(), GaussianZBeamSpotFilter::GaussianZBeamSpotFilter(), GenMuonRadiationAlgorithm::GenMuonRadiationAlgorithm(), HcalQie::getCode(), gen::getEngineReference(), HcalDigitizer::HcalDigitizer(), gen::HijingHadronizer::HijingHadronizer(), HcalSiPM::hitCells(), L1DummyProducer::L1DummyProducer(), L1EmulBias::L1EmulBias(), MixBoostEvtVtxGenerator::MixBoostEvtVtxGenerator(), ParticleReplacerZtautau::ParticleReplacerZtautau(), edm::PileUp::PileUp(), PythiaFilterIsolatedTrack::PythiaFilterIsolatedTrack(), RandomEngineAndDistribution::RandomEngineAndDistribution(), edm::RandomFilter::RandomFilter(), CaloHitRespoNew::ranGauss(), CaloHitRespoNew::ranPois(), gen::ReggeGribovPartonMCHadronizer::ReggeGribovPartonMCHadronizer(), edm::PileUp::reload(), HPDNoiseLibraryReader::setRandomEngine(), cms::SiPixelDigitizer::SiPixelDigitizer(), SiStripDigitizer::SiStripDigitizer(), SubsystemNeutronWriter::SubsystemNeutronWriter(), TxCalculator::TxCalculator(), HcalTB02Analysis::update(), and HcalTB04Analysis::xtalAnalysis().
|
inlinevirtual |
Definition at line 118 of file RandomNumberGenerator.h.
References getEngine().
Referenced by getEngine().
|
inlinevirtual |
Definition at line 119 of file RandomNumberGenerator.h.
References getEngine().
Referenced by getEngine().
|
pure virtual |
Implemented in edm::service::RandomNumberGeneratorService.
Referenced by RandomEngineStateProducer::produce().
|
pure virtual |
Implemented in edm::service::RandomNumberGeneratorService.
Referenced by RandomEngineStateProducer::beginLuminosityBlockProduce().
|
pure virtual |
Exists for backward compatibility.
Implemented in edm::service::RandomNumberGeneratorService.
Referenced by edm::BeamHaloProducer::BeamHaloProducer(), ExternalLHEProducer::beginRunProduce(), LaserBeamsTEC2::GeneratePrimaries(), LaserBeamsBarrel::GeneratePrimaries(), LaserBeamsTEC1::GeneratePrimaries(), and AlignableModifier::setSeed().
|
private |
|
pure virtual |
Implemented in edm::service::RandomNumberGeneratorService.
|
pure virtual |
Implemented in edm::service::RandomNumberGeneratorService.
|
pure virtual |
For debugging purposes only.
Implemented in edm::service::RandomNumberGeneratorService.