Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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
#include "
IOMC/RandomEngine/src/TRandomAdaptor.h
"
7
8
#include "CLHEP/Random/RandomEngine.h"
9
10
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::StreamID
const
& streamID) {
11
edm::Service<edm::RandomNumberGenerator>
rng;
12
if
( ! rng.
isAvailable
() ) {
13
throw
cms::Exception
(
"Configuration"
) <<
14
"RandomNumberGenerator service is not available.\n"
15
"You must add the service in the configuration file\n"
16
"or remove the module that requires it."
;
17
}
18
engine_
= &rng->
getEngine
(streamID);
19
20
// Get the TRandom3 egine, to benefit from Root functional random generation
21
if
(
engine_
->name() ==
"TRandom3"
)
22
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
23
}
24
25
RandomEngineAndDistribution::RandomEngineAndDistribution
(
edm::LuminosityBlockIndex
const
& luminosityBlockIndex) {
26
edm::Service<edm::RandomNumberGenerator>
rng;
27
if
( ! rng.
isAvailable
() ) {
28
throw
cms::Exception
(
"Configuration"
) <<
29
"RandomNumberGenerator service is not available.\n"
30
"You must add the service in the configuration file\n"
31
"or remove the module that requires it."
;
32
}
33
engine_
= &rng->
getEngine
(luminosityBlockIndex);
34
35
// Get the TRandom3 egine, to benefit from Root functional random generation
36
if
(
engine_
->name() ==
"TRandom3"
)
37
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
38
}
39
40
RandomEngineAndDistribution::RandomEngineAndDistribution
() {
41
edm::Service<edm::RandomNumberGenerator>
rng;
42
if
( ! rng.
isAvailable
() ) {
43
throw
cms::Exception
(
"Configuration"
) <<
44
"RandomNumberGenerator service is not available.\n"
45
"You must add the service in the configuration file\n"
46
"or remove the module that requires it."
;
47
}
48
engine_
= &rng->
getEngine
();
49
50
// Get the TRandom3 egine, to benefit from Root functional random generation
51
if
(
engine_
->name() ==
"TRandom3"
)
52
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
53
}
54
55
RandomEngineAndDistribution::~RandomEngineAndDistribution
() {
56
}
edm::Service< edm::RandomNumberGenerator >
TRandomAdaptor.h
RandomNumberGenerator.h
edm::LuminosityBlockIndex
Definition:
LuminosityBlockIndex.h:33
edm::StreamID
Definition:
StreamID.h:30
RandomEngineAndDistribution::~RandomEngineAndDistribution
~RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:55
edm::Service::isAvailable
bool isAvailable() const
Definition:
Service.h:46
Service.h
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
Exception.h
RandomEngineAndDistribution::engine_
CLHEP::HepRandomEngine * engine_
Definition:
RandomEngineAndDistribution.h:64
edm::hlt::Exception
error
Definition:
HLTenums.h:21
RandomEngineAndDistribution::RandomEngineAndDistribution
RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:40
edm::TRandomAdaptor
Definition:
TRandomAdaptor.h:13
RandomEngineAndDistribution::rootEngine_
TRandom3 * rootEngine_
Definition:
RandomEngineAndDistribution.h:65
RandomEngineAndDistribution.h
Generated for CMSSW Reference Manual by
1.8.5