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
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
engine_(
nullptr
),
46
rootEngine_(
nullptr
) {
47
edm::Service<edm::RandomNumberGenerator>
rng;
48
if
( ! rng.
isAvailable
() ) {
49
throw
cms::Exception
(
"Configuration"
) <<
50
"RandomNumberGenerator service is not available.\n"
51
"You must add the service in the configuration file\n"
52
"or remove the module that requires it."
;
53
}
54
engine_
= &rng->
getEngine
();
55
56
// Get the TRandom3 egine, to benefit from Root functional random generation
57
if
(
engine_
->name() ==
"TRandom3"
)
58
rootEngine_
= ( (
edm::TRandomAdaptor
*)
engine_
)->getRootEngine();
59
}
60
61
RandomEngineAndDistribution::~RandomEngineAndDistribution
() {
62
}
edm::Service< edm::RandomNumberGenerator >
TRandomAdaptor.h
RandomNumberGenerator.h
edm::LuminosityBlockIndex
Definition:
LuminosityBlockIndex.h:33
edm::StreamID
Definition:
StreamID.h:30
nullptr
#define nullptr
Definition:
GCC11Compatibility.h:38
RandomEngineAndDistribution::~RandomEngineAndDistribution
~RandomEngineAndDistribution()
Definition:
RandomEngineAndDistribution.cc:61
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:44
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