The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
HepRndmBaseEngine.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 Basic Random Engine 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 "RndmEngine.h"
29#include <CLHEP/Random/Random.h>
30
31// Forward declarations
32namespace CLHEP {
33 class HepRandomEngine;
34}
35
36namespace HepRndm {
37
38 class BaseEngine : public RndmEngine {
39 protected:
40 std::unique_ptr<CLHEP::HepRandomEngine> m_hepEngine;
41
42 public:
43 BaseEngine( const std::string& name, ISvcLocator* loc ) : RndmEngine( name, loc ) {}
44 CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
45 const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
46 // Retrieve single random number
47 double rndm() const override { return m_hepEngine->flat(); }
48
49 StatusCode finalize() override {
50 if ( m_hepEngine ) CLHEP::HepRandom::setTheEngine( nullptr );
51 m_hepEngine.reset();
52 return RndmEngine::finalize();
53 }
54
55 protected:
57 virtual std::unique_ptr<CLHEP::HepRandomEngine> createEngine() = 0;
58 };
59} // namespace HepRndm
const CLHEP::HepRandomEngine * hepEngine() const
double rndm() const override
StatusCode finalize() override
CLHEP::HepRandomEngine * hepEngine()
virtual std::unique_ptr< CLHEP::HepRandomEngine > createEngine()=0
BaseEngine(const std::string &name, ISvcLocator *loc)
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Random Generator engine definition.
Definition RndmEngine.h:51
StatusCode finalize() override
Definition Service.cpp:223
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64