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