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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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