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