Geant4-11
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
CLHEP::NonRandomEngine Class Referenceabstract

#include <NonRandomEngine.h>

Inheritance diagram for CLHEP::NonRandomEngine:
CLHEP::HepRandomEngine

Public Member Functions

double flat ()
 
void flatArray (const int size, double *vect)
 
bool get (const std::vector< unsigned long > &v)
 
virtual std::istream & get (std::istream &is)
 
long getSeed () const
 
const long * getSeeds () const
 
bool getState (const std::vector< unsigned long > &v)
 
virtual std::istream & getState (std::istream &is)
 
std::string name () const
 
 NonRandomEngine ()
 
virtual operator double ()
 
virtual operator float ()
 
virtual operator unsigned int ()
 
bool operator!= (const HepRandomEngine &engine)
 
bool operator== (const HepRandomEngine &engine)
 
std::vector< unsigned long > put () const
 
virtual std::ostream & put (std::ostream &os) const
 
virtual void restoreStatus (const char filename[]="Config.conf")=0
 
virtual void saveStatus (const char filename[]="Config.conf") const =0
 
void setNextRandom (double r)
 
void setRandomInterval (double x)
 
void setRandomSequence (double *s, int n)
 
virtual ~NonRandomEngine ()
 

Static Public Member Functions

static std::string beginTag ()
 
static std::string engineName ()
 
static HepRandomEnginenewEngine (const std::vector< unsigned long > &v)
 
static HepRandomEnginenewEngine (std::istream &is)
 

Static Protected Member Functions

static bool checkFile (std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
 
static double exponent_bit_32 ()
 
static double mantissa_bit_12 ()
 
static double mantissa_bit_24 ()
 
static double mantissa_bit_32 ()
 
static double nearlyTwoToMinus_54 ()
 
static double twoToMinus_32 ()
 
static double twoToMinus_48 ()
 
static double twoToMinus_49 ()
 
static double twoToMinus_53 ()
 

Protected Attributes

long theSeed
 
const long * theSeeds
 

Private Member Functions

virtual void restoreStatus (const char *)
 
virtual void saveStatus (const char *) const
 
virtual void setSeed (long, int)
 
virtual void setSeeds (const long *, int)
 
virtual void showStatus () const
 

Private Attributes

bool intervalHasBeenSet
 
bool nextHasBeenSet
 
double nextRandom
 
unsigned int nInSeq
 
double randomInterval
 
std::vector< double > sequence
 
bool sequenceHasBeenSet
 

Detailed Description

Author

Definition at line 38 of file NonRandomEngine.h.

Constructor & Destructor Documentation

◆ NonRandomEngine()

CLHEP::NonRandomEngine::NonRandomEngine ( )

Definition at line 33 of file NonRandomEngine.cc.

◆ ~NonRandomEngine()

CLHEP::NonRandomEngine::~NonRandomEngine ( )
virtual

Definition at line 40 of file NonRandomEngine.cc.

40{ }

Member Function Documentation

◆ beginTag()

std::string CLHEP::NonRandomEngine::beginTag ( )
static

Definition at line 141 of file NonRandomEngine.cc.

141 {
142 return "NonRandomEngine-begin";
143}

◆ checkFile()

bool CLHEP::HepRandomEngine::checkFile ( std::istream &  file,
const std::string &  filename,
const std::string &  classname,
const std::string &  methodname 
)
staticprotectedinherited

Definition at line 47 of file RandomEngine.cc.

50 {
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}

References geant4_check_module_cycles::file.

Referenced by CLHEP::DualRand::restoreStatus(), CLHEP::HepJamesRandom::restoreStatus(), CLHEP::MTwistEngine::restoreStatus(), CLHEP::RanecuEngine::restoreStatus(), CLHEP::RanluxEngine::restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), and CLHEP::RanshiEngine::restoreStatus().

◆ engineName()

static std::string CLHEP::NonRandomEngine::engineName ( )
inlinestatic

Definition at line 70 of file NonRandomEngine.h.

70{return "NonRandomEngine";}

◆ exponent_bit_32()

static double CLHEP::HepRandomEngine::exponent_bit_32 ( )
inlinestaticprotectedinherited

◆ flat()

double CLHEP::NonRandomEngine::flat ( )
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 65 of file NonRandomEngine.cc.

65 {
66
68 double v = sequence[nInSeq++];
69 if (nInSeq >= sequence.size() ) sequenceHasBeenSet = false;
70 return v;
71 }
72
73 if ( !nextHasBeenSet ) {
74 std::cout
75 << "Attempt to use NonRandomEngine without setting next random!\n";
76 exit(1);
77 }
78
79 double a = nextRandom;
80 nextHasBeenSet = false;
81
84 if ( nextRandom >= 1 ) nextRandom -= 1.0;
85 nextHasBeenSet = true;
86 }
87
88 return a;
89}
std::vector< double > sequence
def exit()
Definition: g4zmq.py:99

References g4zmq::exit(), intervalHasBeenSet, nextHasBeenSet, nextRandom, nInSeq, randomInterval, sequence, and sequenceHasBeenSet.

Referenced by flatArray().

◆ flatArray()

void CLHEP::NonRandomEngine::flatArray ( const int  size,
double *  vect 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 92 of file NonRandomEngine.cc.

92 {
93 for (int i = 0; i < size; ++i) {
94 vect[i] = flat();
95 }
96}

References flat().

◆ get() [1/2]

bool CLHEP::NonRandomEngine::get ( const std::vector< unsigned long > &  v)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 202 of file NonRandomEngine.cc.

202 {
203 if ((v[0] & 0xffffffffUL) != engineIDulong<NonRandomEngine>()) {
204 std::cerr <<
205 "\nNonRandomEngine get:state vector has wrong ID word - state unchanged\n";
206 return false;
207 }
208 return getState(v);
209}
virtual std::istream & getState(std::istream &is)

References getState().

◆ get() [2/2]

std::istream & CLHEP::NonRandomEngine::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 128 of file NonRandomEngine.cc.

128 {
129 std::string beginMarker = "NonRandomEngine-begin";
130 is >> beginMarker;
131 if (beginMarker != "NonRandomEngine-begin") {
132 is.clear(std::ios::badbit | is.rdstate());
133 std::cerr << "\nInput mispositioned or"
134 << "\nNonRandomEngine state description missing or"
135 << "\nwrong engine type found.\n";
136 return is;
137 }
138 return getState(is);
139}

References getState().

◆ getSeed()

long CLHEP::HepRandomEngine::getSeed ( ) const
inlineinherited

Definition at line 112 of file RandomEngine.h.

112{ return theSeed; }

References CLHEP::HepRandomEngine::theSeed.

◆ getSeeds()

const long * CLHEP::HepRandomEngine::getSeeds ( ) const
inlineinherited

Definition at line 115 of file RandomEngine.h.

115{ return theSeeds; }

References CLHEP::HepRandomEngine::theSeeds.

◆ getState() [1/2]

bool CLHEP::NonRandomEngine::getState ( const std::vector< unsigned long > &  v)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 211 of file NonRandomEngine.cc.

211 {
212 unsigned int seqSize = v[9];
213 if (v.size() != 2*seqSize + 10 ) {
214 std::cerr <<
215 "\nNonRandomEngine get:state vector has wrong length - state unchanged\n";
216 std::cerr << " (length = " << v.size()
217 << "; expected " << 2*seqSize + 10 << ")\n";
218 return false;
219 }
220 std::vector<unsigned long> t(2);
221 nextHasBeenSet = (v[1]!=0);
222 sequenceHasBeenSet = (v[2]!=0);
223 intervalHasBeenSet = (v[3]!=0);
224 t[0] = v[4]; t[1] = v[5]; nextRandom = DoubConv::longs2double(t);
225 nInSeq = v[6];
226 t[0] = v[7]; t[1] = v[8]; randomInterval = DoubConv::longs2double(t);
227 sequence.clear();
228 for (unsigned int i=0; i<seqSize; ++i) {
229 t[0] = v[2*i+10]; t[1] = v[2*i+11];
230 sequence.push_back(DoubConv::longs2double(t));
231 }
232 return true;
233}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110

References intervalHasBeenSet, CLHEP::DoubConv::longs2double(), nextHasBeenSet, nextRandom, nInSeq, randomInterval, sequence, and sequenceHasBeenSet.

◆ getState() [2/2]

std::istream & CLHEP::NonRandomEngine::getState ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 145 of file NonRandomEngine.cc.

145 {
146 if ( possibleKeywordInput ( is, "Uvec", nextHasBeenSet ) ) {
147 std::vector<unsigned long> v;
148 unsigned long uu = 99999;
149 unsigned long ssiz = 0;
150 for (unsigned int istart=0; istart < 10; ++istart) {
151 is >> uu;
152 if (!is) {
153 is.clear(std::ios::badbit | is.rdstate());
154 std::cout << "istart = " << istart << "\n";
155 std::cerr
156 << "\nNonRandomEngine state (vector) description has no sequence size."
157 << "\ngetState() has failed."
158 << "\nInput stream is probably mispositioned now." << std::endl;
159 return is;
160 }
161 v.push_back(uu);
162 if (istart==9) ssiz = uu;
163 }
164 for (unsigned int ivec=0; ivec < 2*ssiz; ++ivec) {
165 is >> uu;
166 if (!is) {
167 is.clear(std::ios::badbit | is.rdstate());
168 std::cerr << "\nNonRandomEngine state (vector) description improper."
169 << "\ngetState() has failed."
170 << "\nInput stream is probably mispositioned now." << std::endl;
171 return is;
172 }
173 v.push_back(uu);
174 }
175 getState(v);
176 return (is);
177 }
178
179// is >> nextHasBeenSet; Removed, encompassed by possibleKeywordInput()
180
181 std::string endMarker = "NonRandomEngine-end";
183 is >> nextRandom >> nInSeq >> randomInterval;
184 unsigned int seqSize;
185 is >> seqSize;
186 sequence.clear();
187 double x;
188 for (unsigned int i = 0; i < seqSize; ++i) {
189 is >> x;
190 sequence.push_back(x);
191 }
192 is >> endMarker;
193 if (endMarker != "NonRandomEngine-end") {
194 is.clear(std::ios::badbit | is.rdstate());
195 std::cerr << "\n NonRandomEngine state description incomplete."
196 << "\nInput stream is probably mispositioned now." << std::endl;
197 return is;
198 }
199 return is;
200}
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:166

References getState(), intervalHasBeenSet, nextHasBeenSet, nextRandom, nInSeq, CLHEP::possibleKeywordInput(), randomInterval, sequence, and sequenceHasBeenSet.

Referenced by get(), and getState().

◆ mantissa_bit_12()

static double CLHEP::HepRandomEngine::mantissa_bit_12 ( )
inlinestaticprotectedinherited

◆ mantissa_bit_24()

static double CLHEP::HepRandomEngine::mantissa_bit_24 ( )
inlinestaticprotectedinherited

◆ mantissa_bit_32()

static double CLHEP::HepRandomEngine::mantissa_bit_32 ( )
inlinestaticprotectedinherited

◆ name()

std::string CLHEP::NonRandomEngine::name ( ) const
virtual

◆ nearlyTwoToMinus_54()

static double CLHEP::HepRandomEngine::nearlyTwoToMinus_54 ( )
inlinestaticprotectedinherited

◆ newEngine() [1/2]

HepRandomEngine * CLHEP::HepRandomEngine::newEngine ( const std::vector< unsigned long > &  v)
staticinherited

Definition at line 96 of file RandomEngine.cc.

96 {
98}
static HepRandomEngine * newEngine(std::istream &is)

References CLHEP::EngineFactory::newEngine().

◆ newEngine() [2/2]

HepRandomEngine * CLHEP::HepRandomEngine::newEngine ( std::istream &  is)
staticinherited

Definition at line 91 of file RandomEngine.cc.

91 {
92 return EngineFactory::newEngine(is);
93}

References CLHEP::EngineFactory::newEngine().

Referenced by CLHEP::StaticRandomStates::restore().

◆ operator double()

CLHEP::HepRandomEngine::operator double ( )
virtualinherited

◆ operator float()

CLHEP::HepRandomEngine::operator float ( )
virtualinherited

◆ operator unsigned int()

CLHEP::HepRandomEngine::operator unsigned int ( )
virtualinherited

◆ operator!=()

bool CLHEP::HepRandomEngine::operator!= ( const HepRandomEngine engine)
inlineinherited

◆ operator==()

bool CLHEP::HepRandomEngine::operator== ( const HepRandomEngine engine)
inlineinherited

◆ put() [1/2]

std::vector< unsigned long > CLHEP::NonRandomEngine::put ( ) const
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 108 of file NonRandomEngine.cc.

108 {
109 std::vector<unsigned long> v;
110 v.push_back (engineIDulong<NonRandomEngine>());
111 std::vector<unsigned long> t;
112 v.push_back(static_cast<unsigned long>(nextHasBeenSet));
113 v.push_back(static_cast<unsigned long>(sequenceHasBeenSet));
114 v.push_back(static_cast<unsigned long>(intervalHasBeenSet));
116 v.push_back(t[0]); v.push_back(t[1]);
117 v.push_back(static_cast<unsigned long>(nInSeq));
119 v.push_back(t[0]); v.push_back(t[1]);
120 v.push_back(static_cast<unsigned long>(sequence.size()));
121 for (unsigned int i=0; i<sequence.size(); ++i) {
123 v.push_back(t[0]); v.push_back(t[1]);
124 }
125 return v;
126}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

References CLHEP::DoubConv::dto2longs(), intervalHasBeenSet, nextHasBeenSet, nextRandom, nInSeq, randomInterval, sequence, and sequenceHasBeenSet.

Referenced by put().

◆ put() [2/2]

std::ostream & CLHEP::NonRandomEngine::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 98 of file NonRandomEngine.cc.

98 {
99 std::string beginMarker = "NonRandomEngine-begin";
100 os << beginMarker << "\nUvec\n";
101 std::vector<unsigned long> v = put();
102 for (unsigned int i=0; i<v.size(); ++i) {
103 os << v[i] << "\n";
104 }
105 return os;
106}
std::vector< unsigned long > put() const

References put().

◆ restoreStatus() [1/2]

virtual void CLHEP::NonRandomEngine::restoreStatus ( const char *  )
inlineprivatevirtual

Definition at line 92 of file NonRandomEngine.h.

92{};

◆ restoreStatus() [2/2]

virtual void CLHEP::HepRandomEngine::restoreStatus ( const char  filename[] = "Config.conf")
pure virtualinherited

◆ saveStatus() [1/2]

virtual void CLHEP::NonRandomEngine::saveStatus ( const char *  ) const
inlineprivatevirtual

Definition at line 91 of file NonRandomEngine.h.

91{};

◆ saveStatus() [2/2]

virtual void CLHEP::HepRandomEngine::saveStatus ( const char  filename[] = "Config.conf") const
pure virtualinherited

◆ setNextRandom()

void CLHEP::NonRandomEngine::setNextRandom ( double  r)

Definition at line 43 of file NonRandomEngine.cc.

43 {
44 nextRandom = r;
45 nextHasBeenSet=true;
46 return;
47}

References nextHasBeenSet, and nextRandom.

◆ setRandomInterval()

void CLHEP::NonRandomEngine::setRandomInterval ( double  x)

Definition at line 59 of file NonRandomEngine.cc.

59 {
62 return;
63}

References intervalHasBeenSet, and randomInterval.

◆ setRandomSequence()

void CLHEP::NonRandomEngine::setRandomSequence ( double *  s,
int  n 
)

Definition at line 49 of file NonRandomEngine.cc.

49 {
50 sequence.clear();
51 for (int i=0; i<n; i++) sequence.push_back(*s++);
52 assert (sequence.size() == (unsigned int)n);
53 nInSeq = 0;
55 nextHasBeenSet=false;
56 return;
57}
static constexpr double s

References CLHEP::detail::n, nextHasBeenSet, nInSeq, CLHEP::s, sequence, and sequenceHasBeenSet.

◆ setSeed()

virtual void CLHEP::NonRandomEngine::setSeed ( long  ,
int   
)
inlineprivatevirtual

Implements CLHEP::HepRandomEngine.

Definition at line 89 of file NonRandomEngine.h.

89{};

◆ setSeeds()

virtual void CLHEP::NonRandomEngine::setSeeds ( const long *  ,
int   
)
inlineprivatevirtual

Implements CLHEP::HepRandomEngine.

Definition at line 90 of file NonRandomEngine.h.

90{};

◆ showStatus()

virtual void CLHEP::NonRandomEngine::showStatus ( ) const
inlineprivatevirtual

Implements CLHEP::HepRandomEngine.

Definition at line 93 of file NonRandomEngine.h.

93{};

◆ twoToMinus_32()

static double CLHEP::HepRandomEngine::twoToMinus_32 ( )
inlinestaticprotectedinherited

◆ twoToMinus_48()

static double CLHEP::HepRandomEngine::twoToMinus_48 ( )
inlinestaticprotectedinherited

◆ twoToMinus_49()

static double CLHEP::HepRandomEngine::twoToMinus_49 ( )
inlinestaticprotectedinherited

◆ twoToMinus_53()

static double CLHEP::HepRandomEngine::twoToMinus_53 ( )
inlinestaticprotectedinherited

Field Documentation

◆ intervalHasBeenSet

bool CLHEP::NonRandomEngine::intervalHasBeenSet
private

Definition at line 80 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setRandomInterval().

◆ nextHasBeenSet

bool CLHEP::NonRandomEngine::nextHasBeenSet
private

Definition at line 78 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), setNextRandom(), and setRandomSequence().

◆ nextRandom

double CLHEP::NonRandomEngine::nextRandom
private

Definition at line 81 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setNextRandom().

◆ nInSeq

unsigned int CLHEP::NonRandomEngine::nInSeq
private

Definition at line 83 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setRandomSequence().

◆ randomInterval

double CLHEP::NonRandomEngine::randomInterval
private

Definition at line 84 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setRandomInterval().

◆ sequence

std::vector<double> CLHEP::NonRandomEngine::sequence
private

Definition at line 82 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setRandomSequence().

◆ sequenceHasBeenSet

bool CLHEP::NonRandomEngine::sequenceHasBeenSet
private

Definition at line 79 of file NonRandomEngine.h.

Referenced by flat(), getState(), put(), and setRandomSequence().

◆ theSeed

long CLHEP::HepRandomEngine::theSeed
protectedinherited

Definition at line 142 of file RandomEngine.h.

Referenced by CLHEP::DualRand::DualRand(), CLHEP::HepRandomEngine::getSeed(), CLHEP::DualRand::getState(), CLHEP::HepJamesRandom::getState(), CLHEP::MixMaxRng::getState(), CLHEP::MTwistEngine::getState(), CLHEP::RanecuEngine::getState(), CLHEP::Ranlux64Engine::getState(), CLHEP::RanluxEngine::getState(), CLHEP::RanshiEngine::getState(), CLHEP::HepJamesRandom::HepJamesRandom(), CLHEP::MixMaxRng::MixMaxRng(), CLHEP::RanecuEngine::put(), CLHEP::MixMaxRng::put(), CLHEP::MTwistEngine::put(), CLHEP::RanecuEngine::RanecuEngine(), CLHEP::RanluxEngine::RanluxEngine(), CLHEP::RanluxppEngine::RanluxppEngine(), CLHEP::RanshiEngine::RanshiEngine(), CLHEP::DualRand::restoreStatus(), CLHEP::HepJamesRandom::restoreStatus(), CLHEP::MTwistEngine::restoreStatus(), CLHEP::RanecuEngine::restoreStatus(), CLHEP::RanluxEngine::restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), CLHEP::RanshiEngine::restoreStatus(), CLHEP::MTwistEngine::saveStatus(), CLHEP::RanecuEngine::setIndex(), CLHEP::RanecuEngine::setSeed(), CLHEP::HepJamesRandom::setSeed(), CLHEP::MixMaxRng::setSeed(), CLHEP::RanluxppEngine::setSeed(), CLHEP::Ranlux64Engine::setSeed(), CLHEP::RanluxEngine::setSeed(), CLHEP::DualRand::setSeed(), CLHEP::MTwistEngine::setSeed(), CLHEP::RanecuEngine::setSeeds(), CLHEP::Ranlux64Engine::setSeeds(), CLHEP::RanluxEngine::setSeeds(), CLHEP::MixMaxRng::setSeeds(), CLHEP::RanshiEngine::setSeeds(), CLHEP::DualRand::showStatus(), CLHEP::HepJamesRandom::showStatus(), CLHEP::MTwistEngine::showStatus(), CLHEP::RanecuEngine::showStatus(), CLHEP::Ranlux64Engine::showStatus(), CLHEP::RanluxEngine::showStatus(), and CLHEP::RanshiEngine::showStatus().

◆ theSeeds

const long* CLHEP::HepRandomEngine::theSeeds
protectedinherited

The documentation for this class was generated from the following files: