HepRndm::Engine< TYPE > Class Template Reference

#include <src/RndmGenSvc/HepRndmEngine.h>

Inheritance diagram for HepRndm::Engine< TYPE >:
Collaboration diagram for HepRndm::Engine< TYPE >:

Public Member Functions

 Engine (const std::string &name, ISvcLocator *loc)
 Standard Constructor. More...
 
 ~Engine () override=default
 Standard Destructor. More...
 
StatusCode initialize () override
 Initialize the Engine. More...
 
StatusCode finalize () override
 Finalize the Engine. More...
 
StatusCode setSeeds (const std::vector< long > &seed) override
 Set seeds. More...
 
StatusCode seeds (std::vector< long > &seed) const override
 Retrieve seeds. More...
 
- Public Member Functions inherited from HepRndm::BaseEngine
 BaseEngine (const std::string &name, ISvcLocator *loc)
 
 ~BaseEngine () override=default
 
CLHEP::HepRandomEngine * hepEngine ()
 
const CLHEP::HepRandomEngine * hepEngine () const
 
double rndm () const override
 Single shot returning single random number. More...
 
- Public Member Functions inherited from RndmEngine
virtual StatusCode rndmArray (std::vector< double > &array, long howmany, long start=0) const
 Multiple shots returning vector with flat random numbers. More...
 
virtual StreamBufferserialize (StreamBuffer &str)
 Input serialization from stream buffer. More...
 
virtual StreamBufferserialize (StreamBuffer &str) const
 Output serialization to stream buffer. More...
 
virtual void handle (const Incident &inc)
 Inform that a new incident has occurred. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Attributes

std::vector< long > m_seeds
 
int m_row
 
int m_col
 
int m_lux
 
bool m_useTable
 
bool m_setSingleton
 
- Protected Attributes inherited from HepRndm::BaseEngine
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
 
- Protected Attributes inherited from RndmEngine
SmartIF< IIncidentSvcm_pIncidentSvc
 Reference to the incident service. More...
 

Private Member Functions

std::unique_ptr< CLHEP::HepRandomEngine > createEngine () override
 Create new HepEngine.... More...
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 
template<>
std::unique_ptr< CLHEP::HepRandomEngine > createEngine ()
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from HepRndm::BaseEngine
void initEngine ()
 
- Protected Member Functions inherited from RndmEngine
 RndmEngine (const std::string &name, ISvcLocator *loc)
 Standard Constructor. More...
 
virtual ~RndmEngine ()
 Standard Destructor. More...
 

Detailed Description

template<class TYPE>
class HepRndm::Engine< TYPE >

Definition at line 25 of file HepRndmEngine.h.

Constructor & Destructor Documentation

template<class TYPE >
HepRndm::Engine< TYPE >::Engine ( const std::string &  name,
ISvcLocator loc 
)

Standard Constructor.

Definition at line 56 of file HepRndmEngines.cpp.

57  : BaseEngine (nam, loc) {
58  declareProperty("Seeds", m_seeds);
59  declareProperty("Column", m_col = 0);
60  declareProperty("Row", m_row = 1);
61  declareProperty("Luxury", m_lux = 3);
62  declareProperty("UseTable", m_useTable = false);
63  declareProperty("SetSingleton",m_setSingleton = false);
64  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
BaseEngine(const std::string &name, ISvcLocator *loc)
template<class TYPE >
HepRndm::Engine< TYPE >::~Engine ( )
overridedefault

Standard Destructor.

Member Function Documentation

template<class TYPE >
std::unique_ptr<CLHEP::HepRandomEngine> HepRndm::Engine< TYPE >::createEngine ( )
overrideprivatevirtual

Create new HepEngine....

Implements HepRndm::BaseEngine.

template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< DualRand >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 146 of file HepRndmEngines.cpp.

146  {
147  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new DualRand(m_row, m_col)
148  : new DualRand(m_seeds[0]) );
149  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< TripleRand >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 151 of file HepRndmEngines.cpp.

151  {
152  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new TripleRand(m_row, m_col)
153  : new TripleRand(m_seeds[0]));
154  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< DRand48Engine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 156 of file HepRndmEngines.cpp.

156  {
157  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new DRand48Engine(m_row, m_col)
158  : new DRand48Engine(m_seeds[0]));
159  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< Hurd160Engine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 161 of file HepRndmEngines.cpp.

161  {
162  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Hurd160Engine(m_row, m_col)
163  : new Hurd160Engine(m_seeds[0]));
164  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< Hurd288Engine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 166 of file HepRndmEngines.cpp.

166  {
167  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Hurd288Engine(m_row, m_col)
168  : new Hurd288Engine(m_seeds[0]));
169  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< RanecuEngine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 171 of file HepRndmEngines.cpp.

171  {
172  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new RanecuEngine(m_row)
173  : new RanecuEngine(m_seeds[0]));
174  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< RanshiEngine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 176 of file HepRndmEngines.cpp.

176  {
177  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new RanshiEngine(m_row, m_col)
178  : new RanshiEngine(m_seeds[0]));
179  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< RanluxEngine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 181 of file HepRndmEngines.cpp.

181  {
182  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new RanluxEngine(m_row, m_col, m_lux)
183  : new RanluxEngine(m_seeds[0], m_lux));
184  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< Ranlux64Engine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 186 of file HepRndmEngines.cpp.

186  {
187  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Ranlux64Engine(m_row, m_col, m_lux)
188  : new Ranlux64Engine(m_seeds[0], m_lux));
189  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< MTwistEngine >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 191 of file HepRndmEngines.cpp.

191  {
192  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new MTwistEngine(m_row, m_col)
193  : new MTwistEngine(m_seeds[0]));
194  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<>
std::unique_ptr< CLHEP::HepRandomEngine > HepRndm::Engine< HepJamesRandom >::createEngine ( )
privatevirtual

Implements HepRndm::BaseEngine.

Definition at line 196 of file HepRndmEngines.cpp.

196  {
197  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new HepJamesRandom(m_row, m_col)
198  : new HepJamesRandom(m_seeds[0]) );
199  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<class TYPE >
StatusCode HepRndm::Engine< TYPE >::finalize ( )
overridevirtual

Finalize the Engine.

Reimplemented from HepRndm::BaseEngine.

Definition at line 110 of file HepRndmEngines.cpp.

110  {
111  m_seeds.clear();
112  return BaseEngine::finalize();
113  }
StatusCode finalize() override
Service override: finalization.
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
template<class TYPE >
StatusCode HepRndm::Engine< TYPE >::initialize ( )
overridevirtual

Initialize the Engine.

Reimplemented from RndmEngine.

Definition at line 67 of file HepRndmEngines.cpp.

67  {
68  m_seeds.erase(m_seeds.begin(), m_seeds.end());
70  if ( m_seeds.size() == 0 ) {
71  // Default seeds
72  long theSeed = 1234567;
73  m_seeds.push_back(theSeed);
74  m_seeds.push_back(0);
75  }
76  MsgStream log(msgSvc(), name());
77  if ( status.isSuccess() ) {
78  initEngine();
79  log << MSG::INFO << "Generator engine type:"
80  << System::typeinfoName(typeid(*hepEngine()))
81  << endmsg;
82  if ( m_useTable ) {
83  if ( m_row > 214 || m_col > 1 ) {
84  log << MSG::ERROR << "Generator engine seed table has dimension [215][2], you gave:"
85  << " Row=" << m_row << " Column:" << m_col << endmsg;
86  status = StatusCode::FAILURE;
87  }
88  else {
89  log << MSG::INFO << "Generator engine seeds from table."
90  << " Row=" << m_row << " Column:" << m_col << endmsg;
91  }
92  }
93  log << "Current Seed:" << hepEngine()->getSeed();
94  log << " Luxury:" << m_lux;
95  log << endmsg;
96  // Use the default static engine if required (e.g. for GEANT4)
97  if ( m_setSingleton ) {
98  HepRandom::setTheEngine(hepEngine());
99  log << "This is the GEANT4 engine!" << endmsg;
100  }
101  return status;
102  }
103  log << MSG::ERROR << "Cannot initialze random engine of type:"
104  << System::typeinfoName(typeid(TYPE))
105  << endmsg;
106  return status;
107  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode initialize()
Service override: initialization.
Definition: RndmEngine.cpp:41
CLHEP::HepRandomEngine * hepEngine()
template<class TYPE >
StatusCode HepRndm::Engine< TYPE >::seeds ( std::vector< long > &  seed) const
override

Retrieve seeds.

Definition at line 130 of file HepRndmEngines.cpp.

130  {
131  /*
132  const long *s = hepEngine()->getSeeds();
133  for ( size_t i = 0; i < NUMBER_OF_SEEDS; i++ ) {
134  seed.push_back(s[i]);
135  if ( m_seeds.size() > i )
136  m_seeds[i] = s[i];
137  else
138  m_seeds.push_back(s[i]);
139  }
140  */
141  seed.push_back(hepEngine()->getSeed());
142  return StatusCode::SUCCESS;
143  }
CLHEP::HepRandomEngine * hepEngine()
template<class TYPE >
StatusCode HepRndm::Engine< TYPE >::setSeeds ( const std::vector< long > &  seed)
override

Set seeds.

Definition at line 116 of file HepRndmEngines.cpp.

116  {
117  m_seeds.clear();
118  std::copy(seed.begin(),seed.end(),std::back_inserter(m_seeds));
119  if ( !m_seeds.empty() ) {
120  if ( m_seeds.back() != 0 ) {
121  m_seeds.push_back(0);
122  }
123  hepEngine()->setSeeds(&m_seeds[0], m_lux);
124  return StatusCode::SUCCESS;
125  }
126  return StatusCode::FAILURE;
127  }
std::vector< long > m_seeds
Definition: HepRndmEngine.h:28
CLHEP::HepRandomEngine * hepEngine()

Member Data Documentation

template<class TYPE >
int HepRndm::Engine< TYPE >::m_col
protected

Definition at line 30 of file HepRndmEngine.h.

template<class TYPE >
int HepRndm::Engine< TYPE >::m_lux
protected

Definition at line 30 of file HepRndmEngine.h.

template<class TYPE >
int HepRndm::Engine< TYPE >::m_row
protected

Definition at line 30 of file HepRndmEngine.h.

template<class TYPE >
std::vector<long> HepRndm::Engine< TYPE >::m_seeds
mutableprotected

Definition at line 28 of file HepRndmEngine.h.

template<class TYPE >
bool HepRndm::Engine< TYPE >::m_setSingleton
protected

Definition at line 31 of file HepRndmEngine.h.

template<class TYPE >
bool HepRndm::Engine< TYPE >::m_useTable
protected

Definition at line 31 of file HepRndmEngine.h.


The documentation for this class was generated from the following files: