The Gaudi Framework  v33r1 (b1225454)
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
double shoot() const override
Single shot.
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Generator(IInterface *engine)
StatusCode initialize(const IRndmGen::Param &par) override
Initialize the generator.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Definition of the basic interface.
Definition: IInterface.h:254
StatusCode initialize(const IRndmGen::Param &par) override
IRndmGen implementation.
Definition: RndmGen.cpp:36
Random Generator definition.
Definition: RndmGen.h:51
bool isSuccess() const
Definition: StatusCode.h:365
constexpr static const auto FAILURE
Definition: StatusCode.h:101
CLHEP::HepRandomEngine * m_hepEngine
CLHEP::HepRandomEngine * hepEngine()