The Gaudi Framework  v33r0 (d5ea422b)
HepRndmBaseEngine.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 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 "CLHEP/Random/Random.h"
30 #include "RndmEngine.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
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
StatusCode finalize() override
Definition: Service.cpp:174
StatusCode finalize() override
std::unique_ptr< CLHEP::HepRandomEngine > m_hepEngine
virtual std::unique_ptr< CLHEP::HepRandomEngine > createEngine()=0
STL class.
double rndm() const override
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
const CLHEP::HepRandomEngine * hepEngine() const
BaseEngine(const std::string &name, ISvcLocator *loc)
T reset(T... args)
T get(T... args)
Random Generator engine definition.
Definition: RndmEngine.h:52
CLHEP::HepRandomEngine * hepEngine()