Geant4 Cross Reference |
>> 1 // $Id:$ 1 // -*- C++ -*- 2 // -*- C++ -*- 2 // 3 // 3 // ------------------------------------------- 4 // ----------------------------------------------------------------------- 4 // HEP Random 5 // HEP Random 5 // --- RanecuEngine --- 6 // --- RanecuEngine --- 6 // class implementation f 7 // class implementation file 7 // ------------------------------------------- 8 // ----------------------------------------------------------------------- 8 // This file is part of Geant4 (simulation too 9 // This file is part of Geant4 (simulation toolkit for HEP). 9 // 10 // 10 // RANECU Random Engine - algorithm originally 11 // RANECU Random Engine - algorithm originally written in FORTRAN77 11 // as part of the MATHL 12 // as part of the MATHLIB HEP library. 12 13 13 // =========================================== 14 // ======================================================================= 14 // Gabriele Cosmo - Created - 2nd February 199 15 // Gabriele Cosmo - Created - 2nd February 1996 15 // - Minor corrections: 31st Oc 16 // - Minor corrections: 31st October 1996 16 // - Added methods for engine s 17 // - Added methods for engine status: 19th November 1996 17 // - Added abs for setting seed 18 // - Added abs for setting seed index: 11th July 1997 18 // - Modified setSeeds() to han 19 // - Modified setSeeds() to handle default index: 16th Oct 1997 19 // - setSeed() now resets the e 20 // - setSeed() now resets the engine status to the original 20 // values in the static table 21 // values in the static table of HepRandom: 19th Mar 1998 21 // J.Marraffino - Added stream operators and 22 // J.Marraffino - Added stream operators and related constructor. 22 // Added automatic seed selec 23 // Added automatic seed selection from seed table and 23 // engine counter: 16th Feb 1 24 // engine counter: 16th Feb 1998 24 // Ken Smith - Added conversion operators 25 // Ken Smith - Added conversion operators: 6th Aug 1998 25 // J. Marraffino - Remove dependence on hepSt 26 // J. Marraffino - Remove dependence on hepString class 13 May 1999 26 // M. Fischler - Add endl to the end of sav 27 // M. Fischler - Add endl to the end of saveStatus 10 Apr 2001 27 // M. Fischler - In restore, checkFile for 28 // M. Fischler - In restore, checkFile for file not found 03 Dec 2004 28 // M. Fischler - Methods for distrib. insta 29 // M. Fischler - Methods for distrib. instance save/restore 12/8/04 29 // M. Fischler - split get() into tag valid 30 // M. Fischler - split get() into tag validation and 30 // getState() for anonymous r 31 // getState() for anonymous restores 12/27/04 31 // M. Fischler - put/get for vectors of ulo 32 // M. Fischler - put/get for vectors of ulongs 3/14/05 32 // M. Fischler - State-saving using only in 33 // M. Fischler - State-saving using only ints, for portability 4/12/05 33 // M. Fischler - Modify ctor and setSeed to 34 // M. Fischler - Modify ctor and setSeed to utilize all info provided 34 // and avoid coincidence of s 35 // and avoid coincidence of same state from different 35 // seeds 36 // seeds 6/22/10 36 // 37 // 37 // =========================================== 38 // ======================================================================= 38 39 39 #include "CLHEP/Random/Random.h" 40 #include "CLHEP/Random/Random.h" 40 #include "CLHEP/Random/RanecuEngine.h" 41 #include "CLHEP/Random/RanecuEngine.h" 41 #include "CLHEP/Random/engineIDulong.h" 42 #include "CLHEP/Random/engineIDulong.h" 42 #include "CLHEP/Utility/atomic_int.h" << 43 << 44 #include <atomic> << 45 #include <cstdlib> << 46 #include <cmath> << 47 #include <iostream> << 48 #include <string> << 49 #include <string.h> // for strcmp 43 #include <string.h> // for strcmp 50 #include <vector> << 44 #include <cmath> >> 45 #include <cstdlib> 51 46 52 namespace CLHEP { 47 namespace CLHEP { 53 48 54 namespace { << 55 // Number of instances with automatic seed s << 56 CLHEP_ATOMIC_INT_TYPE numberOfEngines(0); << 57 } << 58 << 59 static const int MarkerLen = 64; // Enough roo 49 static const int MarkerLen = 64; // Enough room to hold a begin or end marker. 60 50 61 static const double prec = 4.6566128E-10; 51 static const double prec = 4.6566128E-10; 62 52 63 std::string RanecuEngine::name() const {return 53 std::string RanecuEngine::name() const {return "RanecuEngine";} 64 54 65 void RanecuEngine::further_randomize (int seq1 55 void RanecuEngine::further_randomize (int seq1, int col, int index, int modulus) 66 { 56 { 67 table[seq1][col] -= (index&0x3FFFFFFF); 57 table[seq1][col] -= (index&0x3FFFFFFF); 68 while (table[seq1][col] <= 0) table[seq1][co 58 while (table[seq1][col] <= 0) table[seq1][col] += (modulus-1); 69 } // mf 6/22/10 59 } // mf 6/22/10 70 60 >> 61 // Number of instances with automatic seed selection >> 62 int RanecuEngine::numEngines = 0; >> 63 71 RanecuEngine::RanecuEngine() 64 RanecuEngine::RanecuEngine() 72 : HepRandomEngine() 65 : HepRandomEngine() 73 { 66 { 74 int numEngines = numberOfEngines++; << 75 int cycle = std::abs(int(numEngines/maxSeq)) 67 int cycle = std::abs(int(numEngines/maxSeq)); 76 seq = std::abs(int(numEngines%maxSeq)); 68 seq = std::abs(int(numEngines%maxSeq)); 77 << 69 numEngines += 1; 78 theSeed = seq; 70 theSeed = seq; 79 long mask = ((cycle & 0x007fffff) << 8); 71 long mask = ((cycle & 0x007fffff) << 8); 80 for (int i=0; i<2; ++i) { 72 for (int i=0; i<2; ++i) { 81 for (int j=0; j<maxSeq; ++j) { 73 for (int j=0; j<maxSeq; ++j) { 82 HepRandom::getTheTableSeeds(table[j],j); 74 HepRandom::getTheTableSeeds(table[j],j); 83 table[j][i] ^= mask; 75 table[j][i] ^= mask; 84 } 76 } 85 } 77 } 86 theSeeds = &table[seq][0]; 78 theSeeds = &table[seq][0]; 87 } 79 } 88 80 89 RanecuEngine::RanecuEngine(int index) 81 RanecuEngine::RanecuEngine(int index) 90 : HepRandomEngine() 82 : HepRandomEngine() 91 { 83 { 92 int cycle = std::abs(int(index/maxSeq)); 84 int cycle = std::abs(int(index/maxSeq)); 93 seq = std::abs(int(index%maxSeq)); 85 seq = std::abs(int(index%maxSeq)); 94 theSeed = seq; 86 theSeed = seq; 95 long mask = ((cycle & 0x000007ff) << 20); 87 long mask = ((cycle & 0x000007ff) << 20); 96 for (int j=0; j<maxSeq; ++j) { 88 for (int j=0; j<maxSeq; ++j) { 97 HepRandom::getTheTableSeeds(table[j],j); 89 HepRandom::getTheTableSeeds(table[j],j); 98 table[j][0] ^= mask; 90 table[j][0] ^= mask; 99 table[j][1] ^= mask; 91 table[j][1] ^= mask; 100 } 92 } 101 theSeeds = &table[seq][0]; 93 theSeeds = &table[seq][0]; 102 further_randomize (seq, 0, index, shift1); 94 further_randomize (seq, 0, index, shift1); // mf 6/22/10 103 } 95 } 104 96 105 RanecuEngine::RanecuEngine(std::istream& is) 97 RanecuEngine::RanecuEngine(std::istream& is) 106 : HepRandomEngine() 98 : HepRandomEngine() 107 { 99 { 108 is >> *this; 100 is >> *this; 109 } 101 } 110 102 111 RanecuEngine::~RanecuEngine() {} 103 RanecuEngine::~RanecuEngine() {} 112 104 113 void RanecuEngine::setSeed(long index, int dum 105 void RanecuEngine::setSeed(long index, int dum) 114 { 106 { 115 seq = std::abs(int(index%maxSeq)); 107 seq = std::abs(int(index%maxSeq)); 116 theSeed = seq; 108 theSeed = seq; 117 HepRandom::getTheTableSeeds(table[seq],seq); 109 HepRandom::getTheTableSeeds(table[seq],seq); 118 theSeeds = &table[seq][0]; 110 theSeeds = &table[seq][0]; 119 further_randomize (seq, 0, (int)index, shift << 111 further_randomize (seq, 0, index, shift1); // mf 6/22/10 120 further_randomize (seq, 1, dum, shift2); 112 further_randomize (seq, 1, dum, shift2); // mf 6/22/10 121 } 113 } 122 114 123 void RanecuEngine::setSeeds(const long* seeds, 115 void RanecuEngine::setSeeds(const long* seeds, int pos) 124 { 116 { 125 if (pos != -1) { 117 if (pos != -1) { 126 seq = std::abs(int(pos%maxSeq)); 118 seq = std::abs(int(pos%maxSeq)); 127 theSeed = seq; 119 theSeed = seq; 128 } 120 } 129 // only positive seeds are allowed 121 // only positive seeds are allowed 130 table[seq][0] = std::abs(seeds[0])%shift1; 122 table[seq][0] = std::abs(seeds[0])%shift1; 131 table[seq][1] = std::abs(seeds[1])%shift2; 123 table[seq][1] = std::abs(seeds[1])%shift2; 132 theSeeds = &table[seq][0]; 124 theSeeds = &table[seq][0]; 133 } 125 } 134 126 135 void RanecuEngine::setIndex(long index) 127 void RanecuEngine::setIndex(long index) 136 { 128 { 137 seq = std::abs(int(index%maxSeq)); 129 seq = std::abs(int(index%maxSeq)); 138 theSeed = seq; 130 theSeed = seq; 139 theSeeds = &table[seq][0]; 131 theSeeds = &table[seq][0]; 140 } 132 } 141 133 142 void RanecuEngine::saveStatus( const char file 134 void RanecuEngine::saveStatus( const char filename[] ) const 143 { 135 { 144 std::ofstream outFile( filename, std::ios:: 136 std::ofstream outFile( filename, std::ios::out ) ; 145 137 146 if (!outFile.bad()) { 138 if (!outFile.bad()) { 147 outFile << "Uvec\n"; 139 outFile << "Uvec\n"; 148 std::vector<unsigned long> v = put(); 140 std::vector<unsigned long> v = put(); 149 for (unsigned int i=0; i<v.size(); ++i) { 141 for (unsigned int i=0; i<v.size(); ++i) { 150 outFile << v[i] << "\n"; 142 outFile << v[i] << "\n"; 151 } 143 } 152 } 144 } 153 } 145 } 154 146 155 void RanecuEngine::restoreStatus( const char f 147 void RanecuEngine::restoreStatus( const char filename[] ) 156 { 148 { 157 std::ifstream inFile( filename, std::ios::in 149 std::ifstream inFile( filename, std::ios::in); 158 if (!checkFile ( inFile, filename, engineNam 150 if (!checkFile ( inFile, filename, engineName(), "restoreStatus" )) { 159 std::cerr << " -- Engine state remains un 151 std::cerr << " -- Engine state remains unchanged\n"; 160 return; 152 return; 161 } 153 } 162 if ( possibleKeywordInput ( inFile, "Uvec", 154 if ( possibleKeywordInput ( inFile, "Uvec", theSeed ) ) { 163 std::vector<unsigned long> v; 155 std::vector<unsigned long> v; 164 unsigned long xin; 156 unsigned long xin; 165 for (unsigned int ivec=0; ivec < VECTOR_ST 157 for (unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) { 166 inFile >> xin; 158 inFile >> xin; 167 if (!inFile) { 159 if (!inFile) { 168 inFile.clear(std::ios::badbit | inFile 160 inFile.clear(std::ios::badbit | inFile.rdstate()); 169 std::cerr << "\nJamesRandom state (vec 161 std::cerr << "\nJamesRandom state (vector) description improper." 170 << "\nrestoreStatus has failed." 162 << "\nrestoreStatus has failed." 171 << "\nInput stream is probably mispos 163 << "\nInput stream is probably mispositioned now." << std::endl; 172 return; 164 return; 173 } 165 } 174 v.push_back(xin); 166 v.push_back(xin); 175 } 167 } 176 getState(v); 168 getState(v); 177 return; 169 return; 178 } 170 } 179 171 180 if (!inFile.bad() && !inFile.eof()) { 172 if (!inFile.bad() && !inFile.eof()) { 181 // inFile >> theSeed; removed -- encompas 173 // inFile >> theSeed; removed -- encompased by possibleKeywordInput 182 for (int i=0; i<2; ++i) 174 for (int i=0; i<2; ++i) 183 inFile >> table[theSeed][i]; 175 inFile >> table[theSeed][i]; 184 seq = int(theSeed); 176 seq = int(theSeed); 185 } 177 } 186 } 178 } 187 179 188 void RanecuEngine::showStatus() const 180 void RanecuEngine::showStatus() const 189 { 181 { 190 std::cout << std::endl; 182 std::cout << std::endl; 191 std::cout << "--------- Ranecu engine statu 183 std::cout << "--------- Ranecu engine status ---------" << std::endl; 192 std::cout << " Initial seed (index) = " << 184 std::cout << " Initial seed (index) = " << theSeed << std::endl; 193 std::cout << " Current couple of seeds = " 185 std::cout << " Current couple of seeds = " 194 << table[theSeed][0] << ", " 186 << table[theSeed][0] << ", " 195 << table[theSeed][1] << std::endl; 187 << table[theSeed][1] << std::endl; 196 std::cout << "----------------------------- 188 std::cout << "----------------------------------------" << std::endl; 197 } 189 } 198 190 199 double RanecuEngine::flat() 191 double RanecuEngine::flat() 200 { 192 { 201 const int index = seq; 193 const int index = seq; 202 long seed1 = table[index][0]; 194 long seed1 = table[index][0]; 203 long seed2 = table[index][1]; 195 long seed2 = table[index][1]; 204 196 205 int k1 = (int)(seed1/ecuyer_b); 197 int k1 = (int)(seed1/ecuyer_b); 206 int k2 = (int)(seed2/ecuyer_e); 198 int k2 = (int)(seed2/ecuyer_e); 207 199 208 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*ecu 200 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*ecuyer_c; 209 if (seed1 < 0) seed1 += shift1; 201 if (seed1 < 0) seed1 += shift1; 210 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*ecu 202 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*ecuyer_f; 211 if (seed2 < 0) seed2 += shift2; 203 if (seed2 < 0) seed2 += shift2; 212 204 213 table[index][0] = seed1; 205 table[index][0] = seed1; 214 table[index][1] = seed2; 206 table[index][1] = seed2; 215 207 216 long diff = seed1-seed2; 208 long diff = seed1-seed2; 217 209 218 if (diff <= 0) diff += (shift1-1); 210 if (diff <= 0) diff += (shift1-1); 219 return (double)(diff*prec); 211 return (double)(diff*prec); 220 } 212 } 221 213 222 void RanecuEngine::flatArray(const int size, d 214 void RanecuEngine::flatArray(const int size, double* vect) 223 { 215 { 224 const int index = seq; 216 const int index = seq; 225 long seed1 = table[index][0]; 217 long seed1 = table[index][0]; 226 long seed2 = table[index][1]; 218 long seed2 = table[index][1]; 227 int k1, k2; 219 int k1, k2; 228 int i; 220 int i; 229 221 230 for (i=0; i<size; ++i) 222 for (i=0; i<size; ++i) 231 { 223 { 232 k1 = (int)(seed1/ecuyer_b); 224 k1 = (int)(seed1/ecuyer_b); 233 k2 = (int)(seed2/ecuyer_e); 225 k2 = (int)(seed2/ecuyer_e); 234 226 235 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*e 227 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*ecuyer_c; 236 if (seed1 < 0) seed1 += shift1; 228 if (seed1 < 0) seed1 += shift1; 237 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*e 229 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*ecuyer_f; 238 if (seed2 < 0) seed2 += shift2; 230 if (seed2 < 0) seed2 += shift2; 239 231 240 long diff = seed1-seed2; 232 long diff = seed1-seed2; 241 if (diff <= 0) diff += (shift1-1); 233 if (diff <= 0) diff += (shift1-1); 242 234 243 vect[i] = (double)(diff*prec); 235 vect[i] = (double)(diff*prec); 244 } 236 } 245 table[index][0] = seed1; 237 table[index][0] = seed1; 246 table[index][1] = seed2; 238 table[index][1] = seed2; 247 } << 248 << 249 RanecuEngine::operator double() { << 250 return flat(); << 251 } << 252 << 253 RanecuEngine::operator float() { << 254 return float( flat() ); << 255 } 239 } 256 240 257 RanecuEngine::operator unsigned int() { 241 RanecuEngine::operator unsigned int() { 258 const int index = seq; 242 const int index = seq; 259 long seed1 = table[index][0]; 243 long seed1 = table[index][0]; 260 long seed2 = table[index][1]; 244 long seed2 = table[index][1]; 261 245 262 int k1 = (int)(seed1/ecuyer_b); 246 int k1 = (int)(seed1/ecuyer_b); 263 int k2 = (int)(seed2/ecuyer_e); 247 int k2 = (int)(seed2/ecuyer_e); 264 248 265 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*ecu 249 seed1 = ecuyer_a*(seed1-k1*ecuyer_b)-k1*ecuyer_c; 266 if (seed1 < 0) seed1 += shift1; 250 if (seed1 < 0) seed1 += shift1; 267 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*ecu 251 seed2 = ecuyer_d*(seed2-k2*ecuyer_e)-k2*ecuyer_f; 268 if (seed2 < 0) seed2 += shift2; 252 if (seed2 < 0) seed2 += shift2; 269 253 270 table[index][0] = seed1; 254 table[index][0] = seed1; 271 table[index][1] = seed2; 255 table[index][1] = seed2; 272 long diff = seed1-seed2; 256 long diff = seed1-seed2; 273 if( diff <= 0 ) diff += (shift1-1); 257 if( diff <= 0 ) diff += (shift1-1); 274 258 275 return ((diff << 1) | (seed1&1))& 0xfffffff 259 return ((diff << 1) | (seed1&1))& 0xffffffff; 276 } 260 } 277 261 278 std::ostream & RanecuEngine::put( std::ostream 262 std::ostream & RanecuEngine::put( std::ostream& os ) const 279 { 263 { 280 char beginMarker[] = "RanecuEngine-begin"; 264 char beginMarker[] = "RanecuEngine-begin"; 281 os << beginMarker << "\nUvec\n"; 265 os << beginMarker << "\nUvec\n"; 282 std::vector<unsigned long> v = put(); 266 std::vector<unsigned long> v = put(); 283 for (unsigned int i=0; i<v.size(); ++i) { 267 for (unsigned int i=0; i<v.size(); ++i) { 284 os << v[i] << "\n"; 268 os << v[i] << "\n"; 285 } 269 } 286 return os; 270 return os; 287 } 271 } 288 272 289 std::vector<unsigned long> RanecuEngine::put ( 273 std::vector<unsigned long> RanecuEngine::put () const { 290 std::vector<unsigned long> v; 274 std::vector<unsigned long> v; 291 v.push_back (engineIDulong<RanecuEngine>()); 275 v.push_back (engineIDulong<RanecuEngine>()); 292 v.push_back(static_cast<unsigned long>(theSe 276 v.push_back(static_cast<unsigned long>(theSeed)); 293 v.push_back(static_cast<unsigned long>(table 277 v.push_back(static_cast<unsigned long>(table[theSeed][0])); 294 v.push_back(static_cast<unsigned long>(table 278 v.push_back(static_cast<unsigned long>(table[theSeed][1])); 295 return v; 279 return v; 296 } 280 } 297 281 298 std::istream & RanecuEngine::get ( std::istrea 282 std::istream & RanecuEngine::get ( std::istream& is ) 299 { 283 { 300 char beginMarker [MarkerLen]; 284 char beginMarker [MarkerLen]; 301 285 302 is >> std::ws; 286 is >> std::ws; 303 is.width(MarkerLen); // causes the next rea 287 is.width(MarkerLen); // causes the next read to the char* to be <= 304 // that many bytes, INCLUDING A TERMINAT 288 // that many bytes, INCLUDING A TERMINATION \0 305 // (Stroustrup, section 21.3.2) 289 // (Stroustrup, section 21.3.2) 306 is >> beginMarker; 290 is >> beginMarker; 307 if (strcmp(beginMarker,"RanecuEngine-begin") 291 if (strcmp(beginMarker,"RanecuEngine-begin")) { 308 is.clear(std::ios::badbit | is.rdstate()) 292 is.clear(std::ios::badbit | is.rdstate()); 309 std::cerr << "\nInput stream mispositione 293 std::cerr << "\nInput stream mispositioned or" 310 << "\nRanecuEngine state description 294 << "\nRanecuEngine state description missing or" 311 << "\nwrong engine type found." << st 295 << "\nwrong engine type found." << std::endl; 312 return is; 296 return is; 313 } 297 } 314 return getState(is); 298 return getState(is); 315 } 299 } 316 300 317 std::string RanecuEngine::beginTag ( ) { 301 std::string RanecuEngine::beginTag ( ) { 318 return "RanecuEngine-begin"; 302 return "RanecuEngine-begin"; 319 } 303 } 320 304 321 std::istream & RanecuEngine::getState ( std::i 305 std::istream & RanecuEngine::getState ( std::istream& is ) 322 { 306 { 323 if ( possibleKeywordInput ( is, "Uvec", theS 307 if ( possibleKeywordInput ( is, "Uvec", theSeed ) ) { 324 std::vector<unsigned long> v; 308 std::vector<unsigned long> v; 325 unsigned long uu; 309 unsigned long uu; 326 for (unsigned int ivec=0; ivec < VECTOR_ST 310 for (unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) { 327 is >> uu; 311 is >> uu; 328 if (!is) { 312 if (!is) { 329 is.clear(std::ios::badbit | is.rdstate 313 is.clear(std::ios::badbit | is.rdstate()); 330 std::cerr << "\nRanecuEngine state (ve 314 std::cerr << "\nRanecuEngine state (vector) description improper." 331 << "\ngetState() has failed." 315 << "\ngetState() has failed." 332 << "\nInput stream is probably mispos 316 << "\nInput stream is probably mispositioned now." << std::endl; 333 return is; 317 return is; 334 } 318 } 335 v.push_back(uu); 319 v.push_back(uu); 336 } 320 } 337 getState(v); 321 getState(v); 338 return (is); 322 return (is); 339 } 323 } 340 324 341 // is >> theSeed; Removed, encompassed by po 325 // is >> theSeed; Removed, encompassed by possibleKeywordInput() 342 char endMarker [MarkerLen]; 326 char endMarker [MarkerLen]; 343 for (int i=0; i<2; ++i) { 327 for (int i=0; i<2; ++i) { 344 is >> table[theSeed][i]; 328 is >> table[theSeed][i]; 345 } 329 } 346 is >> std::ws; 330 is >> std::ws; 347 is.width(MarkerLen); 331 is.width(MarkerLen); 348 is >> endMarker; 332 is >> endMarker; 349 if (strcmp(endMarker,"RanecuEngine-end")) { 333 if (strcmp(endMarker,"RanecuEngine-end")) { 350 is.clear(std::ios::badbit | is.rdstate()) 334 is.clear(std::ios::badbit | is.rdstate()); 351 std::cerr << "\nRanecuEngine state descri 335 std::cerr << "\nRanecuEngine state description incomplete." 352 << "\nInput stream is probably mispos 336 << "\nInput stream is probably mispositioned now." << std::endl; 353 return is; 337 return is; 354 } 338 } 355 339 356 seq = int(theSeed); 340 seq = int(theSeed); 357 return is; 341 return is; 358 } 342 } 359 343 360 bool RanecuEngine::get (const std::vector<unsi 344 bool RanecuEngine::get (const std::vector<unsigned long> & v) { 361 if ((v[0] & 0xffffffffUL) != engineIDulong<R 345 if ((v[0] & 0xffffffffUL) != engineIDulong<RanecuEngine>()) { 362 std::cerr << 346 std::cerr << 363 "\nRanecuEngine get:state vector has wro 347 "\nRanecuEngine get:state vector has wrong ID word - state unchanged\n"; 364 return false; 348 return false; 365 } 349 } 366 return getState(v); 350 return getState(v); 367 } 351 } 368 352 369 bool RanecuEngine::getState (const std::vector 353 bool RanecuEngine::getState (const std::vector<unsigned long> & v) { 370 if (v.size() != VECTOR_STATE_SIZE ) { 354 if (v.size() != VECTOR_STATE_SIZE ) { 371 std::cerr << 355 std::cerr << 372 "\nRanecuEngine get:state vector has wro 356 "\nRanecuEngine get:state vector has wrong length - state unchanged\n"; 373 return false; 357 return false; 374 } 358 } 375 theSeed = v[1]; 359 theSeed = v[1]; 376 table[theSeed][0] = v[2]; 360 table[theSeed][0] = v[2]; 377 table[theSeed][1] = v[3]; 361 table[theSeed][1] = v[3]; 378 seq = int(theSeed); 362 seq = int(theSeed); 379 return true; 363 return true; 380 } 364 } 381 365 382 366 383 } // namespace CLHEP 367 } // namespace CLHEP 384 368