| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
Rndm::Numbers Class Reference

Random number accessor This small class encapsulates the use of the random number generator. More...

`#include <GaudiKernel/RndmGenerators.h>`

Collaboration diagram for Rndm::Numbers:
[legend]

## Public Member Functions
| Numbers ()=default
| Standard constructor. More...
| Numbers (const Numbers &)=default
| Copy constructor. More...
| Numbers (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initializing constructor. More...
virtual | ~Numbers ()
| Standard destructor. More...
virtual StatusCode | initialize (const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
| Initialization. More...
| Numbers (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
SmartIF< IRndmGen > | m_generator
| Pointer to random number generator. More...

## Detailed Description

Random number accessor This small class encapsulates the use of the random number generator.

The sole pupose of this class is to hide the usage of the interface and make the whole thing more user friendly. The object is usable directly after creation.

The typical usage is: Rndm::Numbers numbers(); if ( numbers.initialize(rndmGenSvc, Rndm::Gauss(0.5,0.2)).isSuccess() ) { for ( int i = 0; i < 10; i++ ) { value = numbers(); ... } }

Definition at line 396 of file RndmGenerators.h.

## Constructor & Destructor Documentation

Rndm::Numbers::Numbers | ( |  | ) |
| default

Standard constructor.

Rndm::Numbers::Numbers | ( | const Numbers & |  | ) |
| default

Copy constructor.

Rndm::Numbers::Numbers | ( | const SmartIF< IRndmGenSvc > & | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 11 of file RndmGenerators.cpp.

12 {
13 StatusCode status = initialize( svc, par );
14 if ( !status.isSuccess() ) {
15 throw GaudiException( "Initialization failed !", "Rndm::Numbers", status );
16 }
17 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:23

Rndm::Numbers::~Numbers | ( |  | ) |
| virtual

Standard destructor.

Definition at line 20 of file RndmGenerators.cpp.

20 { finalize().ignore(); }
Rndm::Numbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: RndmGenerators.cpp:30
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:84

Rndm::Numbers::Numbers | ( | IRndmGenSvc * | svc,
|  | const IRndmGen::Param & | par
| ) |  |

Initializing constructor.

Definition at line 41 of file RndmGenerators.cpp.

42 {
43 StatusCode status = initialize( svc, par );
44 if ( !status.isSuccess() ) {
45 throw GaudiException( "Initialization failed !", "Rndm::Numbers", status );
46 }
47 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:23

## Member Function Documentation

StatusCode Rndm::Numbers::finalize | ( |  | ) |
| virtual

Finalization.

Definition at line 30 of file RndmGenerators.cpp.

31 {
32 if ( m_generator ) {
33 m_generator->finalize().ignore();
34 m_generator.reset();
35 }
36 return StatusCode::SUCCESS;
37 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
IRndmGen::finalize
virtual StatusCode finalize()=0
Finalize the generator.
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:84

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

Initialization.

Definition at line 23 of file RndmGenerators.cpp.

24 {
25 if ( svc && !m_generator ) m_generator = svc->generator( par );
26 return m_generator ? StatusCode::SUCCESS : StatusCode::FAILURE;
27 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400
IRndmGenSvc::generator
virtual StatusCode generator(const IRndmGen::Param &par, IRndmGen *&refpGen)=0
Add a Generator factory.
StatusCode::FAILURE
Definition: StatusCode.h:29

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

Initialization.

Definition at line 50 of file RndmGenerators.cpp.

51 {
52 return initialize( SmartIF<IRndmGenSvc>( svc ), par );
53 }
SmartIF< IRndmGenSvc >
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:23

Rndm::Numbers::operator bool | ( |  | ) | const
| inline

Check if the number supply is possible.

Definition at line 422 of file RndmGenerators.h.

422 { return m_generator; }
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400

double Rndm::Numbers::operator() | ( | void |  | ) |
| inline

Operator () for the use within STL.

Definition at line 424 of file RndmGenerators.h.

424 { return this->shoot(); }
Rndm::Numbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: RndmGenerators.h:428

double Rndm::Numbers::pop | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 426 of file RndmGenerators.h.

426 { return this->shoot(); }
Rndm::Numbers::shoot
double shoot()
Pop a new number from the buffer.
Definition: RndmGenerators.h:428

double Rndm::Numbers::shoot | ( |  | ) |
| inline

Pop a new number from the buffer.

Definition at line 428 of file RndmGenerators.h.

428 { return m_generator ? m_generator->shoot() : -1; }
IRndmGen::shoot
virtual double shoot() const =0
Single shot returning single random number according to specified distribution.
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400

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

Pop a new number from the buffer.

Definition at line 430 of file RndmGenerators.h.

431 {
432 return m_generator ? m_generator->shootArray( array, num, start ) : StatusCode::FAILURE;
433 }
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:400
IOTest.start
start
Definition: IOTest.py:99
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
Definition: StatusCode.h:29

## Member Data Documentation

SmartIF<IRndmGen> Rndm::Numbers::m_generator
| protected

Pointer to random number generator.

Definition at line 400 of file RndmGenerators.h.

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

- GaudiKernel/GaudiKernel/RndmGenerators.h
- GaudiKernel/src/Lib/RndmGenerators.cpp