All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  template <class TYPE>
27  class Generator : public RndmGen {
28  public:
29  typedef TYPE Parameters;
30  protected:
31  CLHEP::HepRandomEngine* m_hepEngine;
32  TYPE* m_specs;
33  public:
34  Generator(IInterface* engine);
35  virtual ~Generator();
37  virtual StatusCode initialize(const IRndmGen::Param& par);
39  virtual double shoot() const;
40  };
41 
42  template <class TYPE> Generator<TYPE>::Generator(IInterface* engine)
43  : RndmGen (engine), m_hepEngine(0), m_specs(0) {
44  }
45 
46  template <class TYPE> Generator<TYPE>::~Generator() {
47  }
48 
51  StatusCode status = RndmGen::initialize(par);
52  if ( status.isSuccess() ) {
53  try {
54  m_specs = dynamic_cast<TYPE*>(m_params);
55  if ( 0 != m_specs ) {
56  BaseEngine* engine = dynamic_cast<BaseEngine*>(m_engine);
57  if ( 0 != engine ) {
58  m_hepEngine = engine->hepEngine();
59  if ( 0 != m_hepEngine ) {
60  return StatusCode::SUCCESS;
61  }
62  }
63  }
64  }
65  catch (...) {
66  }
67  }
68  return StatusCode::FAILURE;
69  }
70 }
71 
72 #endif // HEPRNDM_HEPRNDMGENERATOR_H
virtual StatusCode initialize(const IRndmGen::Param &par)
Initialize the generator.
virtual StatusCode initialize(const IRndmGen::Param &par)
IRndmGen implementation.
Definition: RndmGen.cpp:37
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
Generator(IInterface *engine)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
Random Generator definition.
Definition: RndmGen.h:39
virtual double shoot() const
Single shot.
CLHEP::HepRandomEngine * m_hepEngine
CLHEP::HepRandomEngine * hepEngine()