| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

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 "RndmGen.h"
17 #include "GaudiKernel/IRndmEngine.h"
18 #include "GaudiKernel/ISvcLocator.h"
19 #include <algorithm>
20 #include <cfloat>
21
23 RndmGen::RndmGen( IInterface* engine ) : m_engine{engine} {}
24
26 StatusCode RndmGen::initialize( const IRndmGen::Param& par )
27 {
28 m_params.reset( par.clone() );
29 return m_engine ? StatusCode::SUCCESS : StatusCode::FAILURE;
30 }
31
32 StatusCode RndmGen::finalize() { return StatusCode::SUCCESS; }
33
35 StatusCode RndmGen::shootArray( std::vector<double>& array, long howmany, long start ) const
36 {
37 if ( !m_engine ) return StatusCode::FAILURE;
38 array.resize( start + howmany );
39 std::generate_n( std::next( std::begin( array ), start ), howmany, [&]() { return this->shoot(); } );
40 return StatusCode::SUCCESS;
41 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
RndmGen::RndmGen
RndmGen(IInterface *engine)
Standard Constructor.
Definition: RndmGen.cpp:23
std::vector::resize
T resize(T...args)
IRndmEngine.h
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:437
IRndmGen::Param::clone
virtual Param * clone() const =0
Clone parameters.
RndmGen::m_engine
SmartIF< IRndmEngine > m_engine
Hosting service: Access must always be possible.
Definition: RndmGen.h:48
std::next
T next(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
IRndmGen::Param
Definition: IRndmGen.h:40
RndmGen::shootArray
StatusCode shootArray(std::vector< double > &array, long howmany, long start) const override
Multiple shots returning vector with random number according to specified distribution.
Definition: RndmGen.cpp:35
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
RndmGen::initialize
StatusCode initialize(const IRndmGen::Param &par) override
IRndmGen implementation.
Definition: RndmGen.cpp:26
std::generate_n
T generate_n(T...args)
IOTest.start
start
Definition: IOTest.py:99
std::unique_ptr::reset
T reset(T...args)
RndmGen.h
RndmGen::finalize
StatusCode finalize() override
Finalize the generator.
Definition: RndmGen.cpp:32
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:28
std::vector< double >
std::begin
T begin(T...args)
RndmGen::m_params
std::unique_ptr< IRndmGen::Param > m_params
Generation parameters.
Definition: RndmGen.h:46
ISvcLocator.h