All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RndmGen.cpp
Go to the documentation of this file.
1 //====================================================================
2 // Random RndmGen class implementation
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/RndmGen ( The LHCb Offline System)
6 // Author : M.Frank
7 // History :
8 // +---------+----------------------------------------------+--------+
9 // | Date | Comment | Who |
10 // +---------+----------------------------------------------+--------+
11 // | 21/11/99| Initial version. | MF |
12 // +---------+----------------------------------------------+--------+
13 //====================================================================
14 #define GAUDI_RANDOMGENSVC_RNDMGEN_CPP
15 
16 #include <cfloat>
19 #include "RndmGen.h"
20 
22 RndmGen::RndmGen(IInterface* engine) : m_params(0), m_engine(0) {
23  if ( 0 != engine ) {
24  engine->queryInterface(IRndmEngine::interfaceID(), pp_cast<void>(&m_engine)).ignore();
25  }
26 }
27 
30  if ( m_engine ) m_engine->release();
31  m_engine = 0;
32  if ( m_params ) delete m_params;
33  m_params = 0;
34 }
35 
38  m_params = par.clone();
40 }
41 
44  return StatusCode::SUCCESS;
45 }
46 
48 double RndmGen::shoot() const {
49  return DBL_MAX;
50 }
51 
53 StatusCode RndmGen::shootArray( std::vector<double>& array, long howmany, long start) const {
54  if ( 0 != m_engine ) {
55  long cnt = start;
56  array.resize(start+howmany);
57  for ( long i = start, num = start+howmany; i < num; i++ ) {
58  array[cnt++] = shoot();
59  }
60  return StatusCode::SUCCESS;
61  }
62  return StatusCode::FAILURE;
63 }
64 
virtual StatusCode initialize(const IRndmGen::Param &par)
IRndmGen implementation.
Definition: RndmGen.cpp:37
virtual Param * clone() const =0
Clone parameters.
IRndmGen::Param * m_params
Generation parameters.
Definition: RndmGen.h:43
RndmGen(IInterface *engine)
Standard Constructor.
Definition: RndmGen.cpp:22
virtual ~RndmGen()
Standard Destructor.
Definition: RndmGen.cpp:29
virtual StatusCode finalize()
Initialize the generator.
Definition: RndmGen.cpp:43
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
IRndmEngine * m_engine
Hosting service: Access must always be possible.
Definition: RndmGen.h:45
virtual double shoot() const
Single shot returning single random number according to specified distribution.
Definition: RndmGen.cpp:48
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode shootArray(std::vector< double > &array, long howmany, long start) const
Multiple shots returning vector with random number according to specified distribution.
Definition: RndmGen.cpp:53
void ignore() const
Definition: StatusCode.h:107
list i
Definition: ana.py:128
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:171
tuple start
Definition: IOTest.py:88
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.