29#include <CLHEP/Random/Random.h>
36 class HepRandomEngine;
41 template <
typename Engine>
54 std::lock_guard<std::mutex> lock(
m_mutex );
55 return Engine::flat();
57 void flatArray(
const int size,
double* vect )
override {
58 std::lock_guard<std::mutex> lock(
m_mutex );
59 Engine::flatArray( size, vect );
61 void setSeed(
long seed,
int n )
override {
62 std::lock_guard<std::mutex> lock(
m_mutex );
63 return Engine::setSeed( seed, n );
66 std::lock_guard<std::mutex> lock(
m_mutex );
69 void saveStatus(
const char filename[] =
"Config.conf" )
const override {
70 std::lock_guard<std::mutex> lock(
m_mutex );
71 return Engine::saveStatus( filename );
74 std::lock_guard<std::mutex> lock(
m_mutex );
75 return Engine::restoreStatus( filename );
78 std::lock_guard<std::mutex> lock(
m_mutex );
79 return Engine::showStatus();
81 std::ostream&
put( std::ostream& os )
const override {
82 std::lock_guard<std::mutex> lock(
m_mutex );
83 return Engine::put( os );
85 std::istream&
get( std::istream& is )
override {
86 std::lock_guard<std::mutex> lock(
m_mutex );
87 return Engine::get( is );
89 std::istream&
getState( std::istream& is )
override {
90 std::lock_guard<std::mutex> lock(
m_mutex );
91 return Engine::getState( is );
93 std::vector<unsigned long>
put()
const override {
94 std::lock_guard<std::mutex> lock(
m_mutex );
97 bool get(
const std::vector<unsigned long>& v )
override {
98 std::lock_guard<std::mutex> lock(
m_mutex );
99 return Engine::get( v );
101 bool getState(
const std::vector<unsigned long>& v )
override {
102 std::lock_guard<std::mutex> lock(
m_mutex );
103 return Engine::getState( v );
105 operator double()
override {
106 std::lock_guard<std::mutex> lock(
m_mutex );
107 return Engine::operator double();
109 operator float()
override {
110 std::lock_guard<std::mutex> lock(
m_mutex );
111 return Engine::operator float();
113 operator unsigned int()
override {
114 std::lock_guard<std::mutex> lock(
m_mutex );
115 return Engine::operator
unsigned int();
132 if (
m_hepEngine ) { CLHEP::HepRandom::setTheEngine(
nullptr ); }
140 template <
typename Engine,
typename... Args>
143 : std::make_unique<Engine>( std::forward<Args>( args )... ) );
Implementation of property with value of concrete type.
auto create_engine(Args &&... args)
const CLHEP::HepRandomEngine * hepEngine() const
double rndm() const override
StatusCode finalize() override
CLHEP::HepRandomEngine * hepEngine()
virtual std::unique_ptr< CLHEP::HepRandomEngine > createEngine()=0
BaseEngine(const std::string &name, ISvcLocator *loc)
Gaudi::Property< bool > m_threadSafe
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
StatusCode setSeeds(const std::vector< long > &seed) override
Set seeds.
StatusCode seeds(std::vector< long > &seed) const override
Retrieve seeds.
std::ostream & put(std::ostream &os) const override
void setSeed(long seed, int n) override
void restoreStatus(const char filename[]="Config.conf") override
std::istream & get(std::istream &is) override
std::vector< unsigned long > put() const override
std::istream & getState(std::istream &is) override
void flatArray(const int size, double *vect) override
void setSeeds(const long *seeds, int n) override
void saveStatus(const char filename[]="Config.conf") const override
bool getState(const std::vector< unsigned long > &v) override
bool get(const std::vector< unsigned long > &v) override
void showStatus() const override
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Random Generator engine definition.
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
This class is used for returning status codes from appropriate routines.