| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
HiveRndm::HiveNumbers Class Reference

`#include <src/HiveNumbers.h>`

Collaboration diagram for HiveRndm::HiveNumbers:
[legend]

## Public Member Functions
| HiveNumbers ()
| Standard constructor. More...
| HiveNumbers (const HiveNumbers &copy)
| Copy constructor. More...
| HiveNumbers (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initializing constructor. More...
virtual | ~HiveNumbers ()
| Standard destructor. More...
virtual StatusCode | initialize (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initialization. More...
| HiveNumbers (IRndmGenSvc *svc, const IRndmGen::Param &par)
| Initializing constructor. More...
virtual StatusCode | initialize (IRndmGenSvc *svc, const IRndmGen::Param &par)
| Initialization. More...
virtual StatusCode | finalize ()
| Finalization. More...
| operator bool () const
| Check if the number supply is possible. More...
double | operator() ()
| Operator () for the use within STL. More...
double | pop ()
| Pop a new number from the buffer. More...
double | shoot ()
| Pop a new number from the buffer. More...
StatusCode | shootArray (std::vector< double > &array, long num, long start=0)
| Pop a new number from the buffer. More...

## Protected Attributes
IRndmGen * | m_generator
| Pointer to random number generator. More...

## Private Attributes
unsigned int | m_buffer_index
const unsigned int | m_buffer_size
std::vector< double > | m_buffer

## Static Private Attributes
static HiveNumbersMutex | m_genMutex

## Detailed Description

Definition at line 28 of file HiveNumbers.h.

## Constructor & Destructor Documentation

## ◆ HiveNumbers() [1/4]

HiveRndm::HiveNumbers::HiveNumbers | ( |  | ) |

Standard constructor.

Definition at line 15 of file HiveNumbers.cpp.

15 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 ) {
16 m_buffer.reserve( m_buffer_size );
17 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:32
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30
std::vector::reserve
T reserve(T... args)

## ◆ HiveNumbers() [2/4]

HiveRndm::HiveNumbers::HiveNumbers | ( | const HiveNumbers & | copy | ) |

Copy constructor.

Definition at line 20 of file HiveNumbers.cpp.

21 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( copy.m_generator ) {
22 m_buffer.reserve( m_buffer_size );
23 if ( 0 != m_generator ) { m_generator->addRef(); }
24 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
std::copy
T copy(T... args)
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:32
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30
std::vector::reserve
T reserve(T... args)

## ◆ HiveNumbers() [3/4]

HiveRndm::HiveNumbers::HiveNumbers | ( | const SmartIF< IRndmGenSvc > & | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 27 of file HiveNumbers.cpp.

28 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 ) {
29 m_buffer.reserve( m_buffer_size );
30 StatusCode status = initialize( svc, par );
31 if ( !status.isSuccess() ) { throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status ); }
32 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:32
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:38
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30
std::vector::reserve
T reserve(T... args)

## ◆ ~HiveNumbers()

HiveRndm::HiveNumbers::~HiveNumbers | ( |  | ) |
| virtual

Standard destructor.

Definition at line 35 of file HiveNumbers.cpp.

35 { finalize().ignore(); }
HiveRndm::HiveNumbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: HiveNumbers.cpp:48
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153

## ◆ HiveNumbers() [4/4]

HiveRndm::HiveNumbers::HiveNumbers | ( | IRndmGenSvc * | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 59 of file HiveNumbers.cpp.

60 : m_buffer_index( 0 ), m_buffer_size( HIVENUMBERS_BUFFER_SIZE ), m_generator( 0 ) {
61 StatusCode status = initialize( svc, par );
62 if ( !status.isSuccess() ) { throw GaudiException( "Initialization failed !", "HiveRndm::HiveNumbers", status ); }
63 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:38
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30

## Member Function Documentation

## ◆ finalize()

StatusCode HiveRndm::HiveNumbers::finalize | ( |  | ) |
| virtual

Finalization.

Definition at line 48 of file HiveNumbers.cpp.

48 {
49 if ( 0 != m_generator ) {
50 m_generator->finalize().ignore();
51 m_generator->release();
52 m_generator = 0;
53 }
54 return StatusCode::SUCCESS;
55 }
IRndmGen::finalize
virtual StatusCode finalize()=0
Finalize the generator.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
IInterface::release
virtual unsigned long release()=0
Release Interface instance.

## ◆ initialize() [1/2]

StatusCode HiveRndm::HiveNumbers::initialize | ( | const SmartIF< IRndmGenSvc > & | svc,
|  | const IRndmGen::Param & | par
| ) |  |
| virtual

Initialization.

Fix-Me:
  : this is a hack, but I do not have the time to review the correct constantness of all the methods

Definition at line 38 of file HiveNumbers.cpp.

38 {
39 if ( svc.isValid() && 0 == m_generator ) {
42 return svc->generator( par, m_generator );
43 }
44 return StatusCode::FAILURE;
45 }
IRndmGenSvc::generator
virtual StatusCode generator(const IRndmGen::Param &par, IRndmGen *&refpGen)=0
Add a Generator factory.
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ initialize() [2/2]

StatusCode HiveRndm::HiveNumbers::initialize | ( | IRndmGenSvc * | svc,
|  | const IRndmGen::Param & | par
| ) |  |
| virtual

Initialization.

Definition at line 66 of file HiveNumbers.cpp.

66 {
67 return initialize( SmartIF<IRndmGenSvc>( svc ), par );
68 }
SmartIF< IRndmGenSvc >
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:465
HiveRndm::HiveNumbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: HiveNumbers.cpp:38

## ◆ operator bool()

HiveRndm::HiveNumbers::operator bool | ( |  | ) | const
| inline

Check if the number supply is possible.

Definition at line 59 of file HiveNumbers.h.

59 { return m_generator != 0; }
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37

## ◆ operator()()

double HiveRndm::HiveNumbers::operator() | ( |  | ) |
| inline

Operator () for the use within STL.

Definition at line 61 of file HiveNumbers.h.

61 { return this->shoot(); }
HiveRndm::HiveNumbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: HiveNumbers.h:65

## ◆ pop()

double HiveRndm::HiveNumbers::pop | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 63 of file HiveNumbers.h.

63 { return this->shoot(); }
HiveRndm::HiveNumbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: HiveNumbers.h:65

## ◆ shoot()

double HiveRndm::HiveNumbers::shoot | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 65 of file HiveNumbers.h.

65 {
66 if ( 0 != m_generator ) {
67 if ( m_buffer_index == 0 ) { // we are out of numbers
68 this->shootArray( m_buffer, m_buffer_size );
69 m_buffer_index = m_buffer_size - 1;
70 }
71 const double number = m_buffer[m_buffer_index];
72 m_buffer_index--;
73 return number;
74 }
75 return -1;
76 }
HiveRndm::HiveNumbers::m_buffer_size
const unsigned int m_buffer_size
Definition: HiveNumbers.h:31
HiveRndm::HiveNumbers::m_buffer
std::vector< double > m_buffer
Definition: HiveNumbers.h:32
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
HiveRndm::HiveNumbers::shootArray
StatusCode shootArray(std::vector< double > &array, long num, long start=0)
Pop a new number from the buffer.
Definition: HiveNumbers.h:78
HiveRndm::HiveNumbers::m_buffer_index
unsigned int m_buffer_index
Definition: HiveNumbers.h:30

## ◆ shootArray()

StatusCode HiveRndm::HiveNumbers::shootArray | ( | std::vector< double > & | array,
|  | long | num,
|  | long | start = `0`
| ) |  |
| inline

Pop a new number from the buffer.

Definition at line 78 of file HiveNumbers.h.

78 {
79 if ( 0 != m_generator ) {
80 StatusCode status;
81 {
82 HiveNumbersMutex::scoped_lock lock( m_genMutex );
83 status = m_generator->shootArray( array, num, start );
84 }
85 return status;
86 }
87 return StatusCode::FAILURE;
88 }
IOTest.start
def start
Definition: IOTest.py:97
HiveRndm::HiveNumbers::m_generator
IRndmGen * m_generator
Pointer to random number generator.
Definition: HiveNumbers.h:37
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::lock
T lock(T... args)
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:27
IRndmGen::shootArray
virtual StatusCode shootArray(std::vector< double > &array, long howmany, long start=0) const =0
Multiple shots returning vector with random number according to specified distribution.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
HiveRndm::HiveNumbers::m_genMutex
static HiveNumbersMutex m_genMutex
Definition: HiveNumbers.h:33

## Member Data Documentation

## ◆ m_buffer

std::vector<double> HiveRndm::HiveNumbers::m_buffer
| private

Definition at line 32 of file HiveNumbers.h.

## ◆ m_buffer_index

unsigned int HiveRndm::HiveNumbers::m_buffer_index
| private

Definition at line 30 of file HiveNumbers.h.

## ◆ m_buffer_size

const unsigned int HiveRndm::HiveNumbers::m_buffer_size
| private

Definition at line 31 of file HiveNumbers.h.

## ◆ m_generator

IRndmGen* HiveRndm::HiveNumbers::m_generator
| protected

Pointer to random number generator.

Definition at line 37 of file HiveNumbers.h.

## ◆ m_genMutex

HiveRndm::HiveNumbersMutex HiveRndm::HiveNumbers::m_genMutex
| static private

Definition at line 33 of file HiveNumbers.h.

The documentation for this class was generated from the following files:

- GaudiHive/src/HiveNumbers.h
- GaudiHive/src/HiveNumbers.cpp