Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HepRndmGenerator.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
26 
27 // Framework include files
28 #include "RndmGen.h"
29 #include "RndmGenSvc.h"
30 
31 #include "HepRndmBaseEngine.h"
32 
33 namespace HepRndm {
34 
35  template <class TYPE>
36  class Generator : public RndmGen {
37  public:
38  typedef TYPE Parameters;
39 
40  protected:
41  CLHEP::HepRandomEngine* m_hepEngine = nullptr;
42  TYPE* m_specs = nullptr;
43 
44  public:
45  Generator( IInterface* engine ) : RndmGen( engine ) {}
47  StatusCode initialize( const IRndmGen::Param& par ) override;
49  double shoot() const override;
50  };
51 
53  template <class TYPE>
56  if ( status.isSuccess() ) {
57  try {
58  m_specs = dynamic_cast<TYPE*>( m_params.get() );
59  if ( m_specs ) {
60  BaseEngine* engine = dynamic_cast<BaseEngine*>( m_engine.get() );
61  if ( engine ) {
62  m_hepEngine = engine->hepEngine();
63  if ( m_hepEngine ) { return StatusCode::SUCCESS; }
64  }
65  }
66  } catch ( ... ) {}
67  }
68  return StatusCode::FAILURE;
69  }
70 } // namespace HepRndm
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:44
HepRndm::Generator
Definition: HepRndmGenerator.h:36
HepRndm::Generator::m_specs
TYPE * m_specs
Definition: HepRndmGenerator.h:42
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:38
HepRndm::Generator::m_hepEngine
CLHEP::HepRandomEngine * m_hepEngine
Definition: HepRndmGenerator.h:41
RndmGen.h
HepRndm::Generator::initialize
StatusCode initialize(const IRndmGen::Param &par) override
Initialize the generator.
Definition: HepRndmGenerator.h:54
RndmGenSvc.h
HepRndm
Definition: HepRndmBaseEngine.h:36
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:50
StatusCode
Definition: StatusCode.h:64
HepRndm::Generator::Generator
Generator(IInterface *engine)
Definition: HepRndmGenerator.h:45
IRndmGen::Param
Definition: IRndmGen.h:45
HepRndmBaseEngine.h
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
IInterface
Definition: IInterface.h:225
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
HepRndm::Generator::Parameters
TYPE Parameters
Definition: HepRndmGenerator.h:38