| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# Rndm::Numbers Class Reference

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

`#include <RndmGenerators.h>`

Collaboration diagram for Rndm::Numbers:

[legend]

List of all members.

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

## 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 389 of file RndmGenerators.h.

## Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 12 of file RndmGenerators.cpp.

    00013 : m_generator(0)
    00014 {
    00015 }

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

Copy constructor.

Definition at line 18 of file RndmGenerators.cpp.

    00019 : m_generator(copy.m_generator)   {
    00020   if ( 0 != m_generator )   {
    00021     m_generator->addRef();
    00022   }
    00023 }

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

Initializing constructor.

Definition at line 26 of file RndmGenerators.cpp.

    00027 : m_generator(0)
    00028 {
    00029   StatusCode status = initialize(svc, par);
    00030   if (!status.isSuccess()) {
    00031     throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
    00032   }
    00033 }

Rndm::Numbers::~Numbers | ( |  | ) | `[virtual]`

Standard destructor.

Definition at line 36 of file RndmGenerators.cpp.

    00036                          {
    00037   finalize().ignore();
    00038 }

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

Initializing constructor.

Definition at line 63 of file RndmGenerators.cpp.

    00064 : m_generator(0)
    00065 {
    00066   StatusCode status = initialize(svc, par);
    00067   if (!status.isSuccess()) {
    00068     throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
    00069   }
    00070 }

## Member Function Documentation

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

Initialization.

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

Definition at line 41 of file RndmGenerators.cpp.

    00042                                                                 {
    00043   if ( svc.isValid() && 0 == m_generator )   {
    00046     return const_cast<IRndmGenSvc*>(svc.get())->generator( par, m_generator );
    00047   }
    00048   return StatusCode::FAILURE;
    00049 }

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

Initialization.

Definition at line 73 of file RndmGenerators.cpp.

    00073                                                                              {
    00074   return initialize(SmartIF<IRndmGenSvc>(svc), par);
    00075 }

StatusCode Rndm::Numbers::finalize | ( | void |  | ) | `[virtual]`

Finalization.

Definition at line 52 of file RndmGenerators.cpp.

    00052                                    {
    00053   if ( 0 != m_generator )   {
    00054     m_generator->finalize().ignore();
    00055     m_generator->release();
    00056     m_generator = 0;
    00057   }
    00058   return StatusCode::SUCCESS;
    00059 }

Rndm::Numbers::operator bool | ( |  | ) | const`[inline]`

Check if the number supply is possible.

Definition at line 413 of file RndmGenerators.h.

    00413                               {
    00414       return m_generator != 0;
    00415     }

double Rndm::Numbers::operator() | ( |  | ) | `[inline]`

Operator () for the use within STL.

Definition at line 417 of file RndmGenerators.h.

    00417                            {
    00418       return this->shoot();
    00419     }

double Rndm::Numbers::pop | ( |  | ) | `[inline]`

Pop a new number from the buffer.

Definition at line 421 of file RndmGenerators.h.

    00421                     {
    00422       return this->shoot();
    00423     }

double Rndm::Numbers::shoot | ( |  | ) | `[inline]`

Pop a new number from the buffer.

Definition at line 425 of file RndmGenerators.h.

    00425                       {
    00426       if ( 0 != m_generator )   {
    00427         return m_generator->shoot();
    00428       }
    00429       return -1;
    00430     }

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

Pop a new number from the buffer.

Definition at line 432 of file RndmGenerators.h.

    00432                                                                              {
    00433       if ( 0 != m_generator )   {
    00434         return m_generator->shootArray(array, num, start);
    00435       }
    00436       return StatusCode::FAILURE;
    00437     }

## Member Data Documentation

IRndmGen* Rndm::Numbers::m_generator`[protected]`

Pointer to random number generator.

Definition at line 392 of file RndmGenerators.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiKernel/GaudiKernel/RndmGenerators.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiKernel/src/Lib/RndmGenerators.cpp