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