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< Service, IRndmEngine, ISerialize, IIncidentListener >
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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~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...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. 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< Service, IRndmEngine, ISerialize, IIncidentListener >
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 Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- 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...
 
- 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...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. 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)
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
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 145 of file HepRndmEngines.cpp.

145  {
147  : new DualRand(m_seeds[0]) );
148  }
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 150 of file HepRndmEngines.cpp.

150  {
152  : new TripleRand(m_seeds[0]));
153  }
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 155 of file HepRndmEngines.cpp.

155  {
156  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new DRand48Engine(m_row, m_col)
157  : new DRand48Engine(m_seeds[0]));
158  }
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 160 of file HepRndmEngines.cpp.

160  {
161  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Hurd160Engine(m_row, m_col)
162  : new Hurd160Engine(m_seeds[0]));
163  }
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 165 of file HepRndmEngines.cpp.

165  {
166  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Hurd288Engine(m_row, m_col)
167  : new Hurd288Engine(m_seeds[0]));
168  }
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 170 of file HepRndmEngines.cpp.

170  {
171  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new RanecuEngine(m_row)
172  : new RanecuEngine(m_seeds[0]));
173  }
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 175 of file HepRndmEngines.cpp.

175  {
176  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new RanshiEngine(m_row, m_col)
177  : new RanshiEngine(m_seeds[0]));
178  }
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 180 of file HepRndmEngines.cpp.

180  {
182  : new RanluxEngine(m_seeds[0], m_lux));
183  }
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 185 of file HepRndmEngines.cpp.

185  {
186  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new Ranlux64Engine(m_row, m_col, m_lux)
187  : new Ranlux64Engine(m_seeds[0], m_lux));
188  }
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 190 of file HepRndmEngines.cpp.

190  {
191  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new MTwistEngine(m_row, m_col)
192  : new MTwistEngine(m_seeds[0]));
193  }
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 195 of file HepRndmEngines.cpp.

195  {
196  return std::unique_ptr<CLHEP::HepRandomEngine>( m_useTable ? new HepJamesRandom(m_row, m_col)
197  : new HepJamesRandom(m_seeds[0]) );
198  }
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 109 of file HepRndmEngines.cpp.

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

Initialize the Engine.

Reimplemented from RndmEngine.

Definition at line 67 of file HepRndmEngines.cpp.

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

Retrieve seeds.

Definition at line 129 of file HepRndmEngines.cpp.

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

Set seeds.

Definition at line 115 of file HepRndmEngines.cpp.

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