| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

RndmEngine.cpp
Go to the documentation of this file.
1 //====================================================================
2 // Random Engine implementation
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/RndmGen ( The LHCb Offline System)
6 // Author : M.Frank
7 // History :
8 // +---------+----------------------------------------------+---------
9 // | Date | Comment | Who
10 // +---------+----------------------------------------------+---------
11 // | 29/10/99| Initial version | MF
12 // +---------+----------------------------------------------+---------
13 //
14 //====================================================================
15 #define GAUDI_RANDOMGENSVC_RndmEngine_CPP
16
17 // STL include files
18 #include <cfloat>
19
20 // Framework include files
21 #include "GaudiKernel/DataObject.h"
22 #include "GaudiKernel/IDataProviderSvc.h"
23 #include "GaudiKernel/IIncidentSvc.h"
24 #include "GaudiKernel/IMessageSvc.h"
25 #include "GaudiKernel/IOpaqueAddress.h"
26 #include "GaudiKernel/ISvcLocator.h"
27 #include "GaudiKernel/MsgStream.h"
28 #include "RndmEngine.h"
29
31 RndmEngine::RndmEngine( const std::string& name, ISvcLocator* loc ) : base_class( name, loc ) {}
32
34 RndmEngine::~RndmEngine() {}
35
37 StatusCode RndmEngine::initialize()
38 {
39 StatusCode status = Service::initialize();
40 if ( status.isSuccess() ) {
41 status = setProperties();
42 if ( status.isSuccess() ) {
43 m_pIncidentSvc = serviceLocator()->service( "IncidentSvc" );
44 if ( !m_pIncidentSvc ) {
45 status = StatusCode::FAILURE;
46 }
47 }
48 }
49 return status;
50 }
51
53 StatusCode RndmEngine::finalize()
54 {
55 m_pIncidentSvc = 0; // release
56 return Service::finalize();
57 }
58
60 StreamBuffer& RndmEngine::serialize( StreamBuffer& str ) { return str; }
62
64 StreamBuffer& RndmEngine::serialize( StreamBuffer& str ) const { return str; }
65
67 double RndmEngine::rndm() const { return DBL_MAX; }
68
70 void RndmEngine::handle( const Incident& /* inc */ ) {}
71
78 StatusCode RndmEngine::rndmArray( std::vector<double>& array, long howmany, long start ) const
79 {
80 long cnt = start;
81 array.resize( start + howmany );
82 for ( long i = start, num = start + howmany; i < num; i++ ) {
83 array[cnt++] = rndm();
84 }
85 return StatusCode::SUCCESS;
86 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:31
RndmEngine::serialize
StreamBuffer & serialize(StreamBuffer &str) override
Input serialization from stream buffer.
Definition: RndmEngine.cpp:61
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
RndmEngine::RndmEngine
RndmEngine(const std::string &name, ISvcLocator *loc)
Standard Constructor.
Definition: RndmEngine.cpp:31
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
StatusCode::FAILURE
Definition: StatusCode.h:31
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
MsgStream.h
Service::start
StatusCode start() override
Definition: Service.cpp:137
StreamBuffer
The stream buffer is a small object collecting object data.
Definition: StreamBuffer.h:41
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
RndmEngine::finalize
StatusCode finalize() override
Service override: finalization.
Definition: RndmEngine.cpp:53
std::vector::resize
T resize(T...args)
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
IDataProviderSvc.h
RndmEngine::m_pIncidentSvc
SmartIF< IIncidentSvc > m_pIncidentSvc
Reference to the incident service.
Definition: RndmEngine.h:50
IIncidentSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
RndmEngine::initialize
StatusCode initialize() override
Service override: initialization.
Definition: RndmEngine.cpp:37
RndmEngine::handle
void handle(const Incident &inc) override
Inform that a new incident has occurred.
Definition: RndmEngine.cpp:70
IMessageSvc.h
RndmEngine::~RndmEngine
~RndmEngine() override
Standard Destructor.
Definition: RndmEngine.cpp:34
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:295
IOpaqueAddress.h
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:28
std::vector< double >
RndmEngine::rndmArray
StatusCode rndmArray(std::vector< double > &array, long howmany, long start=0) const override
Multiple shots returning vector with flat random numbers.
Definition: RndmEngine.cpp:78
RndmEngine::rndm
double rndm() const override
Single shot returning single random number.
Definition: RndmEngine.cpp:67
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
CommonMessaging
Definition: CommonMessaging.h:62
RndmEngine.h
ISvcLocator.h
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
DataObject.h