CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandomEngine.cc
Go to the documentation of this file.
1 // $Id: RandomEngine.cc,v 1.7 2010/10/25 18:18:47 garren Exp $
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/defs.h"
19 #include "CLHEP/Random/RandomEngine.h"
20 #include "CLHEP/Random/EngineFactory.h"
21 
22 //------------------------- HepRandomEngine ------------------------------
23 
24 namespace CLHEP {
25 
27 : theSeed (19780503L)
28 , theSeeds(&theSeed)
29 { }
30 
32 
33 HepRandomEngine::operator double() {
34  return flat();
35 }
36 
37 HepRandomEngine::operator float() {
38  return float( flat() );
39 }
40 
41 HepRandomEngine::operator unsigned int() {
42  return (unsigned int)( flat() * exponent_bit_32() );
43 }
44 
45 bool
46 HepRandomEngine::checkFile (std::istream & file,
47  const std::string & filename,
48  const std::string & classname,
49  const std::string & methodname) {
50  if (!file) {
51  std::cerr << "Failure to find or open file " << filename <<
52  " in " << classname << "::" << methodname << "()\n";
53  return false;
54  }
55  return true;
56 }
57 
58 std::ostream & HepRandomEngine::put (std::ostream & os) const {
59  std::cerr << "HepRandomEngine::put called -- no effect!\n";
60  return os;
61 }
62 std::istream & HepRandomEngine::get (std::istream & is) {
63  std::cerr << "HepRandomEngine::get called -- no effect!\n";
64  return is;
65 }
66 
67 std::string HepRandomEngine::beginTag ( ) {
68  return "HepRandomEngine-begin";
69 }
70 
71 std::istream & HepRandomEngine::getState ( std::istream & is ) {
72  std::cerr << "HepRandomEngine::getState called -- no effect!\n";
73  return is;
74 }
75 
76 std::vector<unsigned long> HepRandomEngine::put () const {
77  std::cerr << "v=HepRandomEngine::put() called -- no data!\n";
78  std::vector<unsigned long> v;
79  return v;
80 }
81 bool HepRandomEngine::get (const std::vector<unsigned long> & ) {
82  std::cerr << "HepRandomEngine::get(v) called -- no effect!\n";
83  return false;
84 }
85 bool HepRandomEngine::getState (const std::vector<unsigned long> & ) {
86  std::cerr << "HepRandomEngine::getState(v) called -- no effect!\n";
87  return false;
88 }
89 
91  return EngineFactory::newEngine(is);
92 }
93 
95 HepRandomEngine::newEngine(const std::vector<unsigned long> & v) {
96  return EngineFactory::newEngine(v);
97 }
98 
99 std::ostream & operator<< (std::ostream & os, const HepRandomEngine & e) {
100  return e.put(os);
101 }
102 
103 std::istream & operator>> (std::istream & is, HepRandomEngine & e) {
104  return e.get(is);
105 }
106 
107 
108 } // namespace CLHEP
#define double(obj)
Definition: excDblThrow.cc:32
virtual std::vector< unsigned long > put() const
Definition: RandomEngine.cc:76
static HepRandomEngine * newEngine(std::istream &is)
virtual std::ostream & put(std::ostream &os) const
Definition: RandomEngine.cc:58
static HepRandomEngine * newEngine(std::istream &is)
Definition: RandomEngine.cc:90
virtual double flat()=0
virtual std::istream & get(std::istream &is)
Definition: RandomEngine.cc:62
static std::string beginTag()
Definition: RandomEngine.cc:67
std::istream & operator>>(std::istream &is, HepAxisAngle &aa)
Definition: AxisAngle.cc:96
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
Definition: RandomEngine.cc:46
virtual std::istream & getState(std::istream &is)
Definition: RandomEngine.cc:71
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
Definition: AxisAngle.cc:86
static double exponent_bit_32()