All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 "RndmEngine.h"
20 #include "CLHEP/Random/Random.h"
21 
22 // Forward declarations
23 namespace CLHEP {
24  class HepRandomEngine;
25 }
26 
27 namespace HepRndm {
28 
29  class BaseEngine : public RndmEngine {
30  protected:
32  public:
34  : RndmEngine( name, loc ) { }
35  ~BaseEngine() override = default;
36  CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
37  const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
38  // Retrieve single random number
39  double rndm() const override { return m_hepEngine->flat(); }
40 
41  StatusCode finalize() override {
42  if (m_hepEngine) CLHEP::HepRandom::setTheEngine(nullptr);
43  m_hepEngine.reset();
44  return RndmEngine::finalize();
45  }
46 
47  protected:
48  void initEngine() { m_hepEngine = createEngine(); }
49  virtual std::unique_ptr<CLHEP::HepRandomEngine> createEngine() = 0;
50  };
51 }
52 #endif // HEPRNDM_HEPRNDMBASEENGINE_H
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
StatusCode finalize() override
StatusCode finalize() override
Service override: finalization.
Definition: RndmEngine.cpp:56
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
STL class.
double rndm() const override
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
const CLHEP::HepRandomEngine * hepEngine() const
BaseEngine(const std::string &name, ISvcLocator *loc)
T reset(T...args)
T get(T...args)
Random Generator engine definition.
Definition: RndmEngine.h:46
CLHEP::HepRandomEngine * hepEngine()