src
FastSimulation
Utilities
src
RandomEngineAndDistribution.cc
Go to the documentation of this file.
1
#include "
FastSimulation/Utilities/interface/RandomEngineAndDistribution.h
"
2
3
#include "
FWCore/ServiceRegistry/interface/Service.h
"
4
#include "
FWCore/Utilities/interface/RandomNumberGenerator.h
"
5
#include "
FWCore/Utilities/interface/Exception.h
"
6
7
#include "CLHEP/Random/RandomEngine.h"
8
9
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::StreamID
const
& streamID) : engine_(nullptr) {
10
edm::Service<edm::RandomNumberGenerator>
rng;
11
if
(!rng.
isAvailable
()) {
12
throw
cms::Exception
(
"Configuration"
) <<
"RandomNumberGenerator service is not available.\n"
13
"You must add the service in the configuration file\n"
14
"or remove the module that requires it."
;
15
}
16
engine_
= &rng->
getEngine
(streamID);
17
}
18
19
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::LuminosityBlockIndex
const
& luminosityBlockIndex)
20
: engine_(nullptr) {
21
edm::Service<edm::RandomNumberGenerator>
rng;
22
if
(!rng.
isAvailable
()) {
23
throw
cms::Exception
(
"Configuration"
) <<
"RandomNumberGenerator service is not available.\n"
24
"You must add the service in the configuration file\n"
25
"or remove the module that requires it."
;
26
}
27
engine_
= &rng->
getEngine
(luminosityBlockIndex);
28
}
29
30
RandomEngineAndDistribution::~RandomEngineAndDistribution
() {}
edm::Service< edm::RandomNumberGenerator >
Exception
Definition:
hltDiff.cc:245
RandomNumberGenerator.h
edm::LuminosityBlockIndex
Definition:
LuminosityBlockIndex.h:33
edm::StreamID
Definition:
StreamID.h:30
RandomEngineAndDistribution::~RandomEngineAndDistribution
~RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:30
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
RandomEngineAndDistribution::RandomEngineAndDistribution
RandomEngineAndDistribution(edm::StreamID const &)
Definition:
RandomEngineAndDistribution.cc:9
Service.h
Exception.h
RandomEngineAndDistribution::engine_
CLHEP::HepRandomEngine * engine_
Definition:
RandomEngineAndDistribution.h:36
RandomEngineAndDistribution.h
edm::Service::isAvailable
bool isAvailable() const
Definition:
Service.h:40
Generated for CMSSW Reference Manual by
1.8.14