| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 370 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 13 of file RndmGenerators.cpp.

14 {
15 StatusCode status = initialize(svc, par);
16 if (!status.isSuccess()) {
17 throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
18 }
19 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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:27

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

Standard destructor.

Definition at line 22 of file RndmGenerators.cpp.

22 {
23 finalize().ignore();
24 }
Rndm::Numbers::finalize
virtual StatusCode finalize()
Finalization.
Definition: RndmGenerators.cpp:34
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106

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

Initializing constructor.

Definition at line 44 of file RndmGenerators.cpp.

45 {
46 StatusCode status = initialize(svc, par);
47 if (!status.isSuccess()) {
48 throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
49 }
50 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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:27

## Member Function Documentation

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

Finalization.

Definition at line 34 of file RndmGenerators.cpp.

34 {
35 if ( m_generator ) {
36 m_generator->finalize().ignore();
37 m_generator.reset();
38 }
39 return StatusCode::SUCCESS;
40 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
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:373
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106

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

Initialization.

Definition at line 27 of file RndmGenerators.cpp.

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

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

Initialization.

Definition at line 53 of file RndmGenerators.cpp.

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

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

Check if the number supply is possible.

Definition at line 394 of file RndmGenerators.h.

394 {
395 return m_generator;
396 }
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:373

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

Operator () for the use within STL.

Definition at line 398 of file RndmGenerators.h.

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

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

Pop a new number from the buffer.

Definition at line 402 of file RndmGenerators.h.

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

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

Pop a new number from the buffer.

Definition at line 406 of file RndmGenerators.h.

406 {
407 return m_generator ? m_generator->shoot()
408 : -1;
409 }
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:373

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

Pop a new number from the buffer.

Definition at line 411 of file RndmGenerators.h.

411 {
412 return m_generator ? m_generator->shootArray(array, num, start)
413 : StatusCode::FAILURE;
414 }
StatusCode::FAILURE
Definition: StatusCode.h:29
Rndm::Numbers::m_generator
SmartIF< IRndmGen > m_generator
Pointer to random number generator.
Definition: RndmGenerators.h:373
IOTest.start
start
Definition: IOTest.py:88
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.

## Member Data Documentation

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

Pointer to random number generator.

Definition at line 373 of file RndmGenerators.h.

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

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