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
rootEngine_(
nullptr
) {
13
edm::Service<edm::RandomNumberGenerator>
rng;
14
if
( ! rng.
isAvailable
() ) {
15
throw
cms::Exception
(
"Configuration"
) <<
16
"RandomNumberGenerator service is not available.\n"
17
"You must add the service in the configuration file\n"
18
"or remove the module that requires it."
;
19
}
20
engine_
= &rng->
getEngine
(streamID);
21
22
// Get the TRandom3 egine, to benefit from Root functional random generation
23
if
(
engine_
->name() ==
"TRandom3"
)
24
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
25
}
26
27
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::LuminosityBlockIndex
const
& luminosityBlockIndex) :
28
engine_
(
nullptr
),
29
rootEngine_
(
nullptr
) {
30
edm::Service<edm::RandomNumberGenerator>
rng;
31
if
( ! rng.
isAvailable
() ) {
32
throw
cms::Exception
(
"Configuration"
) <<
33
"RandomNumberGenerator service is not available.\n"
34
"You must add the service in the configuration file\n"
35
"or remove the module that requires it."
;
36
}
37
engine_
= &rng->
getEngine
(luminosityBlockIndex);
38
39
// Get the TRandom3 egine, to benefit from Root functional random generation
40
if
(
engine_
->name() ==
"TRandom3"
)
41
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
42
}
43
44
RandomEngineAndDistribution::~RandomEngineAndDistribution
() {
45
}
edm::Service< edm::RandomNumberGenerator >
Exception
Definition:
hltDiff.cc:291
TRandomAdaptor.h
RandomNumberGenerator.h
edm::LuminosityBlockIndex
Definition:
LuminosityBlockIndex.h:33
edm::StreamID
Definition:
StreamID.h:30
RandomEngineAndDistribution::~RandomEngineAndDistribution
~RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:44
nullptr
#define nullptr
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:46
Service.h
Exception.h
RandomEngineAndDistribution::engine_
CLHEP::HepRandomEngine * engine_
Definition:
RandomEngineAndDistribution.h:58
edm::TRandomAdaptor
Definition:
TRandomAdaptor.h:13
RandomEngineAndDistribution::rootEngine_
TRandom3 * rootEngine_
Definition:
RandomEngineAndDistribution.h:59
RandomEngineAndDistribution.h
Generated for CMSSW Reference Manual by
1.8.11