Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
20 
21 //------------------------- HepRandomEngine ------------------------------
22 
23 namespace CLHEP {
24 
26 : theSeed (19780503L)
27 , theSeeds(&theSeed)
28 { }
29 
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 
90  return EngineFactory::newEngine(is);
91 }
92 
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
virtual std::vector< unsigned long > put() const
Definition: RandomEngine.cc:75
virtual std::istream & get(std::istream &is)
Definition: RandomEngine.cc:61
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
Definition: RandomEngine.cc:45
static HepRandomEngine * newEngine(std::istream &is)
static std::string beginTag()
Definition: RandomEngine.cc:66
std::ostream & operator<<(std::ostream &os, const HepRandom &dist)
Definition: Random.cc:216
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
double flat()
Definition: G4AblaRandom.cc:47
virtual std::istream & getState(std::istream &is)
Definition: RandomEngine.cc:70
virtual std::ostream & put(std::ostream &os) const
Definition: RandomEngine.cc:57
std::istream & operator>>(std::istream &is, HepRandom &dist)
Definition: Random.cc:220
static constexpr double L
static HepRandomEngine * newEngine(std::istream &is)
Definition: RandomEngine.cc:89