All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
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  MsgStream log(msgSvc(), name());
35  StatusCode sc;
36 
37  // Initilize random number generators
39  if ( sc.isFailure() ) return sc;
40  sc = m_gaussNumbers.initialize(randSvc(), Rndm::Gauss(0.5,0.2));
41  if ( sc.isFailure() ) return sc;
43  if ( sc.isFailure() ) return sc;
44 
45 
46  // Initiatize Histograms
47  m_gaussHisto = histoSvc()->book( "simple/1", "Gauss", 40, 0., 3.);
48  m_gauss2Histo = histoSvc()->book( "simple/2", "Gauss 2D", 40, 0., 3., 50, 0., 3.);
49  m_expHisto = histoSvc()->book( "simple/3", "Exponential", 40, 0., 3.);
50  m_poissonHisto = histoSvc()->book( "simple/4", "Poisson", 40, 0., 3.);
51 
52  return sc;
53 }
54 
56  MsgStream log(msgSvc(), name());
57  StatusCode sc;
58 
59  m_gaussHisto->fill(m_gaussNumbers(), 1.0 );
61  m_poissonHisto->fill(m_poissonNumbers(), 1.0 );
62  m_expHisto->fill(m_expNumbers(), 1.0 );
63  return sc;
64 }
65 
67  return StatusCode::SUCCESS;
68 }
69