| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

HepRndmGenerator.h
Go to the documentation of this file.
1 //====================================================================
2 // CLHEP Random Generator 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_HEPRNDMGENERATOR_H
16 #define HEPRNDM_HEPRNDMGENERATOR_H 1
17
18 // Framework include files
19 #include "RndmGen.h"
20 #include "RndmGenSvc.h"
21
22 #include "HepRndmBaseEngine.h"
23
24 namespace HepRndm
25 {
26
27 template <class TYPE>
28 class Generator : public RndmGen
29 {
30 public:
31 typedef TYPE Parameters;
32
33 protected:
34 CLHEP::HepRandomEngine* m_hepEngine = nullptr;
35 TYPE* m_specs = nullptr;
36
37 public:
38 Generator( IInterface* engine ) : RndmGen( engine ) {}
39 ~Generator() override = default;
41 StatusCode initialize( const IRndmGen::Param& par ) override;
43 double shoot() const override;
44 };
45
47 template <class TYPE>
48 StatusCode Generator<TYPE>::initialize( const IRndmGen::Param& par )
49 {
50 StatusCode status = RndmGen::initialize( par );
51 if ( status.isSuccess() ) {
52 try {
53 m_specs = dynamic_cast<TYPE*>( m_params.get() );
54 if ( m_specs ) {
55 BaseEngine* engine = dynamic_cast<BaseEngine*>( m_engine.get() );
56 if ( engine ) {
57 m_hepEngine = engine->hepEngine();
58 if ( m_hepEngine ) {
59 return StatusCode::SUCCESS;
60 }
61 }
62 }
63 } catch ( ... ) {
64 }
65 }
66 return StatusCode::FAILURE;
67 }
68 }
69
70 #endif // HEPRNDM_HEPRNDMGENERATOR_H
StatusCode::SUCCESS
Definition: StatusCode.h:31
RndmGenSvc.h
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
HepRndm::Generator::Parameters
TYPE Parameters
Definition: HepRndmGenerator.h:31
HepRndm::Generator::Generator
Generator(IInterface *engine)
Definition: HepRndmGenerator.h:38
HepRndmBaseEngine.h
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:435
RndmGen::m_engine
SmartIF< IRndmEngine > m_engine
Hosting service: Access must always be possible.
Definition: RndmGen.h:48
HepRndm::Generator::initialize
StatusCode initialize(const IRndmGen::Param &par) override
Initialize the generator.
Definition: HepRndmGenerator.h:48
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
IRndmGen::Param
Definition: IRndmGen.h:40
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
RndmGen::initialize
StatusCode initialize(const IRndmGen::Param &par) override
IRndmGen implementation.
Definition: RndmGen.cpp:26
RndmGen.h
RndmGen
Random Generator definition.
Definition: RndmGen.h:41
HepRndm
Definition: HepRndmBaseEngine.h:28
HepRndm::Generator::~Generator
~Generator() override=default
std::unique_ptr::get
T get(T...args)
RndmGen::m_params
std::unique_ptr< IRndmGen::Param > m_params
Generation parameters.
Definition: RndmGen.h:46
HepRndm::Generator::shoot
double shoot() const override
Single shot.
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:31
HepRndm::Generator::m_specs
TYPE * m_specs
Definition: HepRndmGenerator.h:35
HepRndm::Generator
Definition: HepRndmGenerator.h:28
HepRndm::Generator::m_hepEngine
CLHEP::HepRandomEngine * m_hepEngine
Definition: HepRndmGenerator.h:34
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:39