CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // $Id: RandomEngine.cc,v 1.7 2010/10/25 18:18:47 garren Exp $ 00002 // -*- C++ -*- 00003 // 00004 // ------------------------------------------------------------------------ 00005 // HEP Random 00006 // --- HepRandomEngine --- 00007 // class implementation file 00008 // ------------------------------------------------------------------------ 00009 // This file is part of Geant4 (simulation toolkit for HEP). 00010 00011 // ======================================================================== 00012 // Gabriele Cosmo - Created: 5th September 1995 00013 // - Minor corrections: 31st October 1996 00014 // - Moved table of seeds to HepRandom: 19th March 1998 00015 // Ken Smith - Added conversion operators: 6th Aug 1998 00016 // ======================================================================= 00017 00018 #include "CLHEP/Random/defs.h" 00019 #include "CLHEP/Random/RandomEngine.h" 00020 #include "CLHEP/Random/EngineFactory.h" 00021 00022 //------------------------- HepRandomEngine ------------------------------ 00023 00024 namespace CLHEP { 00025 00026 HepRandomEngine::HepRandomEngine() 00027 : theSeed (19780503L) 00028 , theSeeds(&theSeed) 00029 { } 00030 00031 HepRandomEngine::~HepRandomEngine() {} 00032 00033 HepRandomEngine::operator double() { 00034 return flat(); 00035 } 00036 00037 HepRandomEngine::operator float() { 00038 return float( flat() ); 00039 } 00040 00041 HepRandomEngine::operator unsigned int() { 00042 return (unsigned int)( flat() * exponent_bit_32() ); 00043 } 00044 00045 bool 00046 HepRandomEngine::checkFile (std::istream & file, 00047 const std::string & filename, 00048 const std::string & classname, 00049 const std::string & methodname) { 00050 if (!file) { 00051 std::cerr << "Failure to find or open file " << filename << 00052 " in " << classname << "::" << methodname << "()\n"; 00053 return false; 00054 } 00055 return true; 00056 } 00057 00058 std::ostream & HepRandomEngine::put (std::ostream & os) const { 00059 std::cerr << "HepRandomEngine::put called -- no effect!\n"; 00060 return os; 00061 } 00062 std::istream & HepRandomEngine::get (std::istream & is) { 00063 std::cerr << "HepRandomEngine::get called -- no effect!\n"; 00064 return is; 00065 } 00066 00067 std::string HepRandomEngine::beginTag ( ) { 00068 return "HepRandomEngine-begin"; 00069 } 00070 00071 std::istream & HepRandomEngine::getState ( std::istream & is ) { 00072 std::cerr << "HepRandomEngine::getState called -- no effect!\n"; 00073 return is; 00074 } 00075 00076 std::vector<unsigned long> HepRandomEngine::put () const { 00077 std::cerr << "v=HepRandomEngine::put() called -- no data!\n"; 00078 std::vector<unsigned long> v; 00079 return v; 00080 } 00081 bool HepRandomEngine::get (const std::vector<unsigned long> & ) { 00082 std::cerr << "HepRandomEngine::get(v) called -- no effect!\n"; 00083 return false; 00084 } 00085 bool HepRandomEngine::getState (const std::vector<unsigned long> & ) { 00086 std::cerr << "HepRandomEngine::getState(v) called -- no effect!\n"; 00087 return false; 00088 } 00089 00090 HepRandomEngine* HepRandomEngine::newEngine(std::istream& is) { 00091 return EngineFactory::newEngine(is); 00092 } 00093 00094 HepRandomEngine* 00095 HepRandomEngine::newEngine(const std::vector<unsigned long> & v) { 00096 return EngineFactory::newEngine(v); 00097 } 00098 00099 std::ostream & operator<< (std::ostream & os, const HepRandomEngine & e) { 00100 return e.put(os); 00101 } 00102 00103 std::istream & operator>> (std::istream & is, HepRandomEngine & e) { 00104 return e.get(is); 00105 } 00106 00107 00108 } // namespace CLHEP