The Gaudi Framework  v30r3 (a5ef0a68)
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:
35 
36  public:
37  BaseEngine( const std::string& name, ISvcLocator* loc ) : RndmEngine( name, loc ) {}
38  CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
39  const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
40  // Retrieve single random number
41  double rndm() const override { return m_hepEngine->flat(); }
42 
43  StatusCode finalize() override
44  {
45  if ( m_hepEngine ) CLHEP::HepRandom::setTheEngine( nullptr );
46  m_hepEngine.reset();
47  return RndmEngine::finalize();
48  }
49 
50  protected:
51  void initEngine() { m_hepEngine = createEngine(); }
52  virtual std::unique_ptr<CLHEP::HepRandomEngine> createEngine() = 0;
53  };
54 }
55 #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
Definition: Service.cpp:173
StatusCode finalize() override
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:51
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:42
CLHEP::HepRandomEngine * hepEngine()