| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

Public Member Functions | Protected Attributes

# 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.

    : m_generator(0)
    {
    }

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

Copy constructor.

Definition at line 18 of file RndmGenerators.cpp.

    : m_generator(copy.m_generator)   {
      if ( 0 != m_generator )   {
        m_generator->addRef();
      }
    }

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

Initializing constructor.

Definition at line 26 of file RndmGenerators.cpp.

    : m_generator(0)
    {
      StatusCode status = initialize(svc, par);
      if (!status.isSuccess()) {
        throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
      }
    }

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

Standard destructor.

Definition at line 36 of file RndmGenerators.cpp.

                             {
      finalize().ignore();
    }

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

Initializing constructor.

Definition at line 63 of file RndmGenerators.cpp.

    : m_generator(0)
    {
      StatusCode status = initialize(svc, par);
      if (!status.isSuccess()) {
        throw GaudiException ("Initialization failed !", "Rndm::Numbers", status);
      }
    }

## Member Function Documentation

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

Finalization.

Definition at line 52 of file RndmGenerators.cpp.

                                       {
      if ( 0 != m_generator )   {
        m_generator->finalize().ignore();
        m_generator->release();
        m_generator = 0;
      }
      return StatusCode::SUCCESS;
    }

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

Initialization.

Definition at line 73 of file RndmGenerators.cpp.

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

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.

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

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

Check if the number supply is possible.

Definition at line 413 of file RndmGenerators.h.

                                  {
          return m_generator != 0;
        }

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

Operator () for the use within STL.

Definition at line 417 of file RndmGenerators.h.

                               {
          return this->shoot();
        }

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

Pop a new number from the buffer.

Definition at line 421 of file RndmGenerators.h.

                        {
          return this->shoot();
        }

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

Pop a new number from the buffer.

Definition at line 425 of file RndmGenerators.h.

                          {
          if ( 0 != m_generator )   {
            return m_generator->shoot();
          }
          return -1;
        }

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.

                                                                                 {
          if ( 0 != m_generator )   {
            return m_generator->shootArray(array, num, start);
          }
          return StatusCode::FAILURE;
        }

## 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_v23r1/GaudiKernel/GaudiKernel/RndmGenerators.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r1/GaudiKernel/src/Lib/RndmGenerators.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines