The Gaudi Framework  master (37c0b60a)
HepRndmBaseEngine.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef HEPRNDM_HEPRNDMBASEENGINE_H
26 #define HEPRNDM_HEPRNDMBASEENGINE_H 1
27 
28 // Framework include files
29 #include "RndmEngine.h"
30 #include <CLHEP/Random/Random.h>
31 
32 // Forward declarations
33 namespace CLHEP {
34  class HepRandomEngine;
35 }
36 
37 namespace HepRndm {
38 
39  class BaseEngine : public RndmEngine {
40  protected:
42 
43  public:
44  BaseEngine( const std::string& name, ISvcLocator* loc ) : RndmEngine( name, loc ) {}
45  CLHEP::HepRandomEngine* hepEngine() { return m_hepEngine.get(); }
46  const CLHEP::HepRandomEngine* hepEngine() const { return m_hepEngine.get(); }
47  // Retrieve single random number
48  double rndm() const override { return m_hepEngine->flat(); }
49 
50  StatusCode finalize() override {
51  if ( m_hepEngine ) CLHEP::HepRandom::setTheEngine( nullptr );
53  return RndmEngine::finalize();
54  }
55 
56  protected:
59  };
60 } // namespace HepRndm
61 #endif // HEPRNDM_HEPRNDMBASEENGINE_H
HepRndm::BaseEngine::hepEngine
CLHEP::HepRandomEngine * hepEngine()
Definition: HepRndmBaseEngine.h:45
std::string
STL class.
ISvcLocator
Definition: ISvcLocator.h:46
HepRndm::BaseEngine::createEngine
virtual std::unique_ptr< CLHEP::HepRandomEngine > createEngine()=0
HepRndm::BaseEngine::initEngine
void initEngine()
Definition: HepRndmBaseEngine.h:57
HepRndm::BaseEngine
Definition: HepRndmBaseEngine.h:39
HepRndm::BaseEngine::finalize
StatusCode finalize() override
Definition: HepRndmBaseEngine.h:50
std::unique_ptr::get
T get(T... args)
HepRndm::BaseEngine::hepEngine
const CLHEP::HepRandomEngine * hepEngine() const
Definition: HepRndmBaseEngine.h:46
std::unique_ptr::reset
T reset(T... args)
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
HepRndm::BaseEngine::m_hepEngine
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
Definition: HepRndmBaseEngine.h:41
HepRndm
Definition: HepRndmBaseEngine.h:37
RndmEngine.h
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
HepRndm::BaseEngine::rndm
double rndm() const override
Definition: HepRndmBaseEngine.h:48
CLHEP
Definition: HepRndmBaseEngine.h:33
HepRndm::BaseEngine::BaseEngine
BaseEngine(const std::string &name, ISvcLocator *loc)
Definition: HepRndmBaseEngine.h:44
std::unique_ptr< CLHEP::HepRandomEngine >
RndmEngine
Random Generator engine definition.
Definition: RndmEngine.h:52