RandomEngine.cc

Go to the documentation of this file.
00001 // $Id:$
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/RandomEngine.h"
00019 #include "CLHEP/Random/EngineFactory.h"
00020 
00021 //------------------------- HepRandomEngine ------------------------------
00022 
00023 namespace CLHEP {
00024 
00025 HepRandomEngine::HepRandomEngine() 
00026 : theSeed (19780503L)
00027 , theSeeds(&theSeed)
00028 { }
00029 
00030 HepRandomEngine::~HepRandomEngine() {}
00031 
00032 HepRandomEngine::operator double() {
00033   return flat();
00034 }
00035 
00036 HepRandomEngine::operator float() {
00037   return float( flat() );
00038 }
00039 
00040 HepRandomEngine::operator unsigned int() {
00041   return (unsigned int)( flat() * exponent_bit_32() );
00042 }
00043 
00044 bool 
00045 HepRandomEngine::checkFile (std::istream & file, 
00046                          const std::string & filename, 
00047                          const std::string & classname, 
00048                          const std::string & methodname) {
00049   if (!file) {
00050     std::cerr << "Failure to find or open file " << filename <<
00051     " in " << classname << "::" << methodname << "()\n";
00052     return false;
00053   }  
00054   return true;
00055 }                            
00056 
00057 std::ostream & HepRandomEngine::put (std::ostream & os) const {
00058   std::cerr << "HepRandomEngine::put called -- no effect!\n";
00059   return os;
00060 }
00061 std::istream & HepRandomEngine::get (std::istream & is) {
00062   std::cerr << "HepRandomEngine::get called -- no effect!\n";
00063   return is;
00064 }
00065 
00066 std::string HepRandomEngine::beginTag ( ) { 
00067   return "HepRandomEngine-begin"; 
00068 }
00069 
00070 std::istream & HepRandomEngine::getState ( std::istream & is ) {
00071   std::cerr << "HepRandomEngine::getState called -- no effect!\n";
00072   return is;
00073 }
00074 
00075 std::vector<unsigned long> HepRandomEngine::put () const {
00076   std::cerr << "v=HepRandomEngine::put() called -- no data!\n";
00077   std::vector<unsigned long> v;
00078   return v;
00079 }
00080 bool HepRandomEngine::get (const std::vector<unsigned long> & ) {
00081   std::cerr << "HepRandomEngine::get(v) called -- no effect!\n";
00082   return false;
00083 }
00084 bool HepRandomEngine::getState (const std::vector<unsigned long> & ) {
00085   std::cerr << "HepRandomEngine::getState(v) called -- no effect!\n";
00086   return false;
00087 }
00088 
00089 HepRandomEngine* HepRandomEngine::newEngine(std::istream& is) {
00090   return EngineFactory::newEngine(is);
00091 }
00092 
00093 HepRandomEngine* 
00094 HepRandomEngine::newEngine(const std::vector<unsigned long> & v) {
00095   return EngineFactory::newEngine(v);
00096 }
00097 
00098 std::ostream & operator<< (std::ostream & os, const HepRandomEngine & e) {
00099   return e.put(os);
00100 }
00101 
00102 std::istream & operator>> (std::istream & is, HepRandomEngine & e) {
00103   return e.get(is);
00104 }
00105 
00106 
00107 }  // namespace CLHEP

Generated on Mon May 27 17:50:33 2013 for Geant4 by  doxygen 1.4.7