RandomNumberAlg.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "GaudiKernel/SmartIF.h"
5 #include "GaudiKernel/IRndmGen.h"
11 
12 #include "AIDA/IHistogram1D.h"
13 #include "AIDA/IHistogram2D.h"
14 
15 // Example related include files
16 #include "RandomNumberAlg.h"
17 
19 
20 
23 RandomNumberAlg::RandomNumberAlg(const std::string& name, ISvcLocator* pSvcLocator)
24 : Algorithm(name, pSvcLocator) {
25 }
26 
27 // Standard destructor
29 }
30 
31 // The "functional" part of the class: For the EmptyAlgorithm example they do
32 // nothing apart from print out info messages.
34  StatusCode sc;
35 
36  // Initilize random number generators
38  if ( sc.isFailure() ) return sc;
39  sc = m_gaussNumbers.initialize(randSvc(), Rndm::Gauss(0.5,0.2));
40  if ( sc.isFailure() ) return sc;
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 
55  StatusCode sc;
56 
57  m_gaussHisto->fill(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 
65  return StatusCode::SUCCESS;
66 }
67 
virtual ~RandomNumberAlg()
Standard Destructor.
Rndm::Numbers m_expNumbers
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
AIDA::IHistogram1D * m_poissonHisto
SmartIF< IHistogramSvc > & histoSvc() const
The standard histogram service.
Parameters for the Poisson distributed random number generation with a given mean.
STL namespace.
Parameters for the Gauss random number generation.
virtual StatusCode execute()
Event callback.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
Rndm::Numbers m_poissonNumbers
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AIDA::IHistogram2D * m_gauss2Histo
SmartIF< IRndmGenSvc > & randSvc() const
AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
virtual StatusCode initialize()
Customized initialisation.
AIDA::IHistogram1D * m_expHisto
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.
virtual StatusCode initialize(const SmartIF< IRndmGenSvc > &svc, const IRndmGen::Param &par)
Initialization.
Rndm::Numbers m_gaussNumbers
Allocate wrapper for random number generator.
virtual StatusCode finalize()
Customized finalisation.
A small algorithm class using the random number service.
Parameters for the Gauss random number generation.
AIDA::IHistogram1D * m_gaussHisto