The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
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
33namespace 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>
55 StatusCode status = RndmGen::initialize( par );
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 }
69 }
70} // namespace HepRndm
CLHEP::HepRandomEngine * hepEngine()
StatusCode initialize(const IRndmGen::Param &par) override
Initialize the generator.
CLHEP::HepRandomEngine * m_hepEngine
Generator(IInterface *engine)
double shoot() const override
Single shot.
Definition of the basic interface.
Definition IInterface.h:225
SmartIF< IRndmEngine > m_engine
Hosting service: Access must always be possible.
Definition RndmGen.h:56
RndmGen(IInterface *engine)
Standard Constructor.
Definition RndmGen.cpp:33
std::unique_ptr< IRndmGen::Param > m_params
Generation parameters.
Definition RndmGen.h:54
StatusCode initialize(const IRndmGen::Param &par) override
IRndmGen implementation.
Definition RndmGen.cpp:36
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100