| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

HepRndmBaseEngine.h
Go to the documentation of this file.
1 //====================================================================
2 // CLHEP Basic Random Engine definition file
3 //--------------------------------------------------------------------
4 //
5 // Package : HepRndm ( The LHCb Offline System)
6 // Author : M.Frank
7 // History :
8 // +---------+----------------------------------------------+---------
9 // | Date | Comment | Who
10 // +---------+----------------------------------------------+---------
11 // | 29/10/99| Initial version | MF
12 // +---------+----------------------------------------------+---------
13 //
14 //====================================================================
15 #ifndef HEPRNDM_HEPRNDMBASEENGINE_H
16 #define HEPRNDM_HEPRNDMBASEENGINE_H 1
17
18 // Framework include files
19 #include "CLHEP/Random/Random.h"
20 #include "RndmEngine.h"
21
22 // Forward declarations
23 namespace CLHEP
24 {
25 class HepRandomEngine;
26 }
27
28 namespace HepRndm
29 {
30
31 class BaseEngine : public RndmEngine
32 {
33 protected:
34 std::unique_ptr<CLHEP::HepRandomEngine> m_hepEngine;
35
36 public:
37 BaseEngine( const std::string& name, ISvcLocator* loc ) : RndmEngine( name, loc ) {}
38 ~BaseEngine() override = default;
39 CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
40 const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
41 // Retrieve single random number
42 double rndm() const override { return m_hepEngine->flat(); }
43
44 StatusCode finalize() override
45 {
46 if ( m_hepEngine ) CLHEP::HepRandom::setTheEngine( nullptr );
47 m_hepEngine.reset();
48 return RndmEngine::finalize();
49 }
50
51 protected:
52 void initEngine() { m_hepEngine = createEngine(); }
53 virtual std::unique_ptr<CLHEP::HepRandomEngine> createEngine() = 0;
54 };
55 }
56 #endif // HEPRNDM_HEPRNDMBASEENGINE_H
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
HepRndm::BaseEngine::initEngine
void initEngine()
Definition: HepRndmBaseEngine.h:52
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
HepRndm::BaseEngine::finalize
StatusCode finalize() override
Definition: HepRndmBaseEngine.h:44
RndmEngine::finalize
StatusCode finalize() override
Service override: finalization.
Definition: RndmEngine.cpp:53
HepRndm::BaseEngine::m_hepEngine
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
Definition: HepRndmBaseEngine.h:34
std::string
STL class.
HepRndm::BaseEngine::rndm
double rndm() const override
Definition: HepRndmBaseEngine.h:42
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
HepRndm::BaseEngine::hepEngine
const CLHEP::HepRandomEngine * hepEngine() const
Definition: HepRndmBaseEngine.h:40
HepRndm::BaseEngine::BaseEngine
BaseEngine(const std::string &name, ISvcLocator *loc)
Definition: HepRndmBaseEngine.h:37
std::unique_ptr::reset
T reset(T...args)
HepRndm
Definition: HepRndmBaseEngine.h:28
std::unique_ptr::get
T get(T...args)
std::unique_ptr< CLHEP::HepRandomEngine >
CLHEP
Definition: IFuncMinimum.h:16
RndmEngine.h
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:31
RndmEngine
Random Generator engine definition.
Definition: RndmEngine.h:46
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:39