| The Gaudi Framework v32r1 (f65d50dc)

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 class HepRandomEngine;
25 }
26
27 namespace HepRndm {
28
29 class BaseEngine : public RndmEngine {
30 protected:
31 std::unique_ptr<CLHEP::HepRandomEngine> m_hepEngine;
32
33 public:
34 BaseEngine( const std::string& name, ISvcLocator* loc ) : RndmEngine( name, loc ) {}
35 CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
36 const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
37 // Retrieve single random number
38 double rndm() const override { return m_hepEngine->flat(); }
39
40 StatusCode finalize() override {
41 if ( m_hepEngine ) CLHEP::HepRandom::setTheEngine( nullptr );
42 m_hepEngine.reset();
43 return RndmEngine::finalize();
44 }
45
46 protected:
47 void initEngine() { m_hepEngine = createEngine(); }
48 virtual std::unique_ptr<CLHEP::HepRandomEngine> createEngine() = 0;
49 };
50 } // namespace HepRndm
51 #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:47
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:164
HepRndm::BaseEngine::finalize
StatusCode finalize() override
Definition: HepRndmBaseEngine.h:40
HepRndm::BaseEngine::m_hepEngine
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
Definition: HepRndmBaseEngine.h:31
HepRndm::BaseEngine::createEngine
virtual std::unique_ptr< CLHEP::HepRandomEngine > createEngine()=0
std::string
STL class.
HepRndm::BaseEngine::rndm
double rndm() const override
Definition: HepRndmBaseEngine.h:38
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
HepRndm::BaseEngine::hepEngine
const CLHEP::HepRandomEngine * hepEngine() const
Definition: HepRndmBaseEngine.h:36
HepRndm::BaseEngine::BaseEngine
BaseEngine(const std::string &name, ISvcLocator *loc)
Definition: HepRndmBaseEngine.h:34
std::unique_ptr::reset
T reset(T... args)
HepRndm
Definition: HepRndmBaseEngine.h:27
std::unique_ptr::get
T get(T... args)
std::unique_ptr< CLHEP::HepRandomEngine >
CLHEP
Definition: TupleDecorator.h:31
RndmEngine.h
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:29
RndmEngine
Random Generator engine definition.
Definition: RndmEngine.h:42
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:35