Geant4  10.00.p01
RandomEngine.cc
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // ------------------------------------------------------------------------
5 // HEP Random
6 // --- HepRandomEngine ---
7 // class implementation file
8 // ------------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 
11 // ========================================================================
12 // Gabriele Cosmo - Created: 5th September 1995
13 // - Minor corrections: 31st October 1996
14 // - Moved table of seeds to HepRandom: 19th March 1998
15 // Ken Smith - Added conversion operators: 6th Aug 1998
16 // =======================================================================
17 
18 #include "CLHEP/Random/RandomEngine.h"
19 #include "CLHEP/Random/EngineFactory.h"
20 
21 //------------------------- HepRandomEngine ------------------------------
22 
23 namespace CLHEP {
24 
25 HepRandomEngine::HepRandomEngine()
26 : theSeed (19780503L)
27 , theSeeds(&theSeed)
28 { }
29 
30 HepRandomEngine::~HepRandomEngine() {}
31 
32 HepRandomEngine::operator double() {
33  return flat();
34 }
35 
36 HepRandomEngine::operator float() {
37  return float( flat() );
38 }
39 
40 HepRandomEngine::operator unsigned int() {
41  return (unsigned int)( flat() * exponent_bit_32() );
42 }
43 
44 bool
45 HepRandomEngine::checkFile (std::istream & file,
46  const std::string & filename,
47  const std::string & classname,
48  const std::string & methodname) {
49  if (!file) {
50  std::cerr << "Failure to find or open file " << filename <<
51  " in " << classname << "::" << methodname << "()\n";
52  return false;
53  }
54  return true;
55 }
56 
57 std::ostream & HepRandomEngine::put (std::ostream & os) const {
58  std::cerr << "HepRandomEngine::put called -- no effect!\n";
59  return os;
60 }
61 std::istream & HepRandomEngine::get (std::istream & is) {
62  std::cerr << "HepRandomEngine::get called -- no effect!\n";
63  return is;
64 }
65 
66 std::string HepRandomEngine::beginTag ( ) {
67  return "HepRandomEngine-begin";
68 }
69 
70 std::istream & HepRandomEngine::getState ( std::istream & is ) {
71  std::cerr << "HepRandomEngine::getState called -- no effect!\n";
72  return is;
73 }
74 
75 std::vector<unsigned long> HepRandomEngine::put () const {
76  std::cerr << "v=HepRandomEngine::put() called -- no data!\n";
77  std::vector<unsigned long> v;
78  return v;
79 }
80 bool HepRandomEngine::get (const std::vector<unsigned long> & ) {
81  std::cerr << "HepRandomEngine::get(v) called -- no effect!\n";
82  return false;
83 }
84 bool HepRandomEngine::getState (const std::vector<unsigned long> & ) {
85  std::cerr << "HepRandomEngine::getState(v) called -- no effect!\n";
86  return false;
87 }
88 
89 HepRandomEngine* HepRandomEngine::newEngine(std::istream& is) {
90  return EngineFactory::newEngine(is);
91 }
92 
93 HepRandomEngine*
94 HepRandomEngine::newEngine(const std::vector<unsigned long> & v) {
95  return EngineFactory::newEngine(v);
96 }
97 
98 std::ostream & operator<< (std::ostream & os, const HepRandomEngine & e) {
99  return e.put(os);
100 }
101 
102 std::istream & operator>> (std::istream & is, HepRandomEngine & e) {
103  return e.get(is);
104 }
105 
106 
107 } // namespace CLHEP
static const G4int L[nN]
std::istream & operator>>(std::istream &is, HepRandomEngine &e)
std::ostream & operator<<(std::ostream &os, const HepRandomEngine &e)
Definition: RandomEngine.cc:98
double flat()
Definition: G4AblaRandom.cc:47