Main Page
Namespaces
Classes
Package Documentation
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) :
11
engine_(
nullptr
) {
12
edm::Service<edm::RandomNumberGenerator>
rng;
13
if
( ! rng.
isAvailable
() ) {
14
throw
cms::Exception
(
"Configuration"
) <<
15
"RandomNumberGenerator service is not available.\n"
16
"You must add the service in the configuration file\n"
17
"or remove the module that requires it."
;
18
}
19
engine_
= &rng->
getEngine
(streamID);
20
}
21
22
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::LuminosityBlockIndex
const
& luminosityBlockIndex) :
23
engine_
(
nullptr
) {
24
edm::Service<edm::RandomNumberGenerator>
rng;
25
if
( ! rng.
isAvailable
() ) {
26
throw
cms::Exception
(
"Configuration"
) <<
27
"RandomNumberGenerator service is not available.\n"
28
"You must add the service in the configuration file\n"
29
"or remove the module that requires it."
;
30
}
31
engine_
= &rng->
getEngine
(luminosityBlockIndex);
32
}
33
34
RandomEngineAndDistribution::~RandomEngineAndDistribution
() {
35
}
edm::Service< edm::RandomNumberGenerator >
Exception
Definition:
hltDiff.cc:292
TRandomAdaptor.h
RandomNumberGenerator.h
edm::LuminosityBlockIndex
Definition:
LuminosityBlockIndex.h:33
edm::StreamID
Definition:
StreamID.h:30
nullptr
#define nullptr
Definition:
GCC11Compatibility.h:37
RandomEngineAndDistribution::~RandomEngineAndDistribution
~RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:34
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:10
edm::Service::isAvailable
bool isAvailable() const
Definition:
Service.h:40
Service.h
Exception.h
RandomEngineAndDistribution::engine_
CLHEP::HepRandomEngine * engine_
Definition:
RandomEngineAndDistribution.h:43
RandomEngineAndDistribution.h
Generated for CMSSW Reference Manual by
1.8.11