| The Gaudi Framework v27r1

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

- File List
- File Members

RandomNumberAlg.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "GaudiKernel/SmartIF.h"
3 #include "GaudiKernel/MsgStream.h"
4 #include "GaudiKernel/ISvcLocator.h"
5 #include "GaudiKernel/IRndmGen.h"
6 #include "GaudiKernel/IRndmGenSvc.h"
7 #include "GaudiKernel/IHistogramSvc.h"
8 #include "GaudiKernel/IDataProviderSvc.h"
9 #include "GaudiKernel/DataObject.h"
10 #include "GaudiKernel/SmartDataPtr.h"
11
12 #include "AIDA/IHistogram1D.h"
13 #include "AIDA/IHistogram2D.h"
14
15 // Example related include files
16 #include "RandomNumberAlg.h"
17
18 DECLARE_COMPONENT(RandomNumberAlg)
19
20
23 RandomNumberAlg::RandomNumberAlg(const std::string& name, ISvcLocator* pSvcLocator)
24 : Algorithm(name, pSvcLocator) {
25 }
26
27 // Standard destructor
28 RandomNumberAlg::~RandomNumberAlg() {
29 }
30
31 // The "functional" part of the class: For the EmptyAlgorithm example they do
32 // nothing apart from print out info messages.
33 StatusCode RandomNumberAlg::initialize() {
34 StatusCode sc;
35
36 // Initilize random number generators
37 sc = m_poissonNumbers.initialize(randSvc(), Rndm::Poisson(0.3));
38 if ( sc.isFailure() ) return sc;
39 sc = m_gaussNumbers.initialize(randSvc(), Rndm::Gauss(0.5,0.2));
40 if ( sc.isFailure() ) return sc;
41 sc = m_expNumbers.initialize(randSvc(), Rndm::Exponential(0.2));
42 if ( sc.isFailure() ) return sc;
43
44
45 // Initiatize Histograms
46 m_gaussHisto = histoSvc()->book( "simple/1", "Gauss", 40, 0., 3.);
47 m_gauss2Histo = histoSvc()->book( "simple/2", "Gauss 2D", 40, 0., 3., 50, 0., 3.);
48 m_expHisto = histoSvc()->book( "simple/3", "Exponential", 40, 0., 3.);
49 m_poissonHisto = histoSvc()->book( "simple/4", "Poisson", 40, 0., 3.);
50
51 return sc;
52 }
53
54 StatusCode RandomNumberAlg::execute() {
55 StatusCode sc;
56
57 m_gaussHisto->fill(m_gaussNumbers(), 1.0 );
58 m_gauss2Histo->fill(m_gaussNumbers(), m_gaussNumbers(), 1.0 );
59 m_poissonHisto->fill(m_poissonNumbers(), 1.0 );
60 m_expHisto->fill(m_expNumbers(), 1.0 );
61 return sc;
62 }
63
64 StatusCode RandomNumberAlg::finalize() {
65 return StatusCode::SUCCESS;
66 }
67
RandomNumberAlg::~RandomNumberAlg
virtual ~RandomNumberAlg()
Standard Destructor.
Definition: RandomNumberAlg.cpp:28
RandomNumberAlg::m_expNumbers
Rndm::Numbers m_expNumbers
Definition: RandomNumberAlg.h:25
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
RandomNumberAlg::m_poissonHisto
AIDA::IHistogram1D * m_poissonHisto
Definition: RandomNumberAlg.h:29
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
MsgStream.h
Algorithm::histoSvc
SmartIF< IHistogramSvc > & histoSvc() const
The standard histogram service.
Rndm::Poisson
Parameters for the Poisson distributed random number generation with a given mean.
Definition: RndmGenerators.h:208
RandomNumberAlg.h
std
STL namespace.
IRndmGen.h
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:21
RandomNumberAlg::execute
virtual StatusCode execute()
Event callback.
Definition: RandomNumberAlg.cpp:54
merge_files.sc
int sc
Definition: merge_files.py:167
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
IDataProviderSvc.h
RandomNumberAlg::m_poissonNumbers
Rndm::Numbers m_poissonNumbers
Definition: RandomNumberAlg.h:24
SmartDataPtr.h
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
RandomNumberAlg::m_gauss2Histo
AIDA::IHistogram2D * m_gauss2Histo
Definition: RandomNumberAlg.h:28
SmartIF.h
Algorithm::randSvc
SmartIF< IRndmGenSvc > & randSvc() const
AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
RandomNumberAlg::initialize
virtual StatusCode initialize()
Customized initialisation.
Definition: RandomNumberAlg.cpp:33
RandomNumberAlg::m_expHisto
AIDA::IHistogram1D * m_expHisto
Definition: RandomNumberAlg.h:30
IRndmGenSvc.h
IHistogramSvc::book
virtual AIDA::IHistogram1D * book(const std::string &fullPath, const std::string &title, int binsX, double lowX, double highX)=0
Book histogram and register it with the histogram data store.
Rndm::Numbers::initialize
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Definition: RndmGenerators.cpp:27
RandomNumberAlg::m_gaussNumbers
Rndm::Numbers m_gaussNumbers
Allocate wrapper for random number generator.
Definition: RandomNumberAlg.h:23
RandomNumberAlg::finalize
virtual StatusCode finalize()
Customized finalisation.
Definition: RandomNumberAlg.cpp:64
RandomNumberAlg
A small algorithm class using the random number service.
Definition: RandomNumberAlg.h:20
Rndm::Exponential
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:47
RandomNumberAlg::m_gaussHisto
AIDA::IHistogram1D * m_gaussHisto
Definition: RandomNumberAlg.h:27
ISvcLocator.h
DataObject.h
IHistogramSvc.h