The Gaudi Framework  master (37c0b60a)
HepRndmGenerator.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 //====================================================================
12 // CLHEP Random Generator definition file
13 //--------------------------------------------------------------------
14 //
15 // Package : HepRndm ( The LHCb Offline System)
16 // Author : M.Frank
17 // History :
18 // +---------+----------------------------------------------+---------
19 // | Date | Comment | Who
20 // +---------+----------------------------------------------+---------
21 // | 29/10/99| Initial version | MF
22 // +---------+----------------------------------------------+---------
23 //
24 //====================================================================
25 #ifndef HEPRNDM_HEPRNDMGENERATOR_H
26 #define HEPRNDM_HEPRNDMGENERATOR_H 1
27 
28 // Framework include files
29 #include "RndmGen.h"
30 #include "RndmGenSvc.h"
31 
32 #include "HepRndmBaseEngine.h"
33 
34 namespace HepRndm {
35 
36  template <class TYPE>
37  class Generator : public RndmGen {
38  public:
39  typedef TYPE Parameters;
40 
41  protected:
42  CLHEP::HepRandomEngine* m_hepEngine = nullptr;
43  TYPE* m_specs = nullptr;
44 
45  public:
46  Generator( IInterface* engine ) : RndmGen( engine ) {}
48  StatusCode initialize( const IRndmGen::Param& par ) override;
50  double shoot() const override;
51  };
52 
54  template <class TYPE>
57  if ( status.isSuccess() ) {
58  try {
59  m_specs = dynamic_cast<TYPE*>( m_params.get() );
60  if ( m_specs ) {
61  BaseEngine* engine = dynamic_cast<BaseEngine*>( m_engine.get() );
62  if ( engine ) {
63  m_hepEngine = engine->hepEngine();
64  if ( m_hepEngine ) { return StatusCode::SUCCESS; }
65  }
66  }
67  } catch ( ... ) {}
68  }
69  return StatusCode::FAILURE;
70  }
71 } // namespace HepRndm
72 
73 #endif // HEPRNDM_HEPRNDMGENERATOR_H
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:45
HepRndm::Generator
Definition: HepRndmGenerator.h:37
HepRndm::Generator::m_specs
TYPE * m_specs
Definition: HepRndmGenerator.h:43
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:39
HepRndm::Generator::m_hepEngine
CLHEP::HepRandomEngine * m_hepEngine
Definition: HepRndmGenerator.h:42
RndmGen.h
HepRndm::Generator::initialize
StatusCode initialize(const IRndmGen::Param &par) override
Initialize the generator.
Definition: HepRndmGenerator.h:55
RndmGenSvc.h
HepRndm
Definition: HepRndmBaseEngine.h:37
HepRndm::Generator::shoot
double shoot() const override
Single shot.
compareOutputFiles.par
par
Definition: compareOutputFiles.py:477
RndmGen::initialize
StatusCode initialize(const IRndmGen::Param &par) override
IRndmGen implementation
Definition: RndmGen.cpp:36
RndmGen
Random Generator definition.
Definition: RndmGen.h:51
StatusCode
Definition: StatusCode.h:65
HepRndm::Generator::Generator
Generator(IInterface *engine)
Definition: HepRndmGenerator.h:46
IRndmGen::Param
Definition: IRndmGen.h:49
HepRndmBaseEngine.h
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IInterface
Definition: IInterface.h:239
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
HepRndm::Generator::Parameters
TYPE Parameters
Definition: HepRndmGenerator.h:39