4 #include "CLHEP/Random/engineIDulong.h"
6 #include "TBufferFile.h"
18 theSeed =
trand_->GetSeed();
21 theSeed =
trand_->GetSeed();
24 theSeed =
trand_->GetSeed();
40 std::vector<unsigned long>
v;
42 int32_t itemSize =
sizeof(uint32_t);
43 TBufferFile buffer(TBuffer::kWrite, 2048 * itemSize);
46 char* bufferPtr = buffer.Buffer();
47 int32_t numItems = (buffer.Length() + itemSize - 1) / itemSize;
48 v.reserve(numItems + 1);
49 v.push_back(CLHEP::engineIDulong<TRandomAdaptor>());
50 for(
int i = 0;
i < numItems; ++
i) {
60 uint32_t value32 = *
reinterpret_cast<uint32_t*
>(bufferPtr +
i * itemSize);
62 if(
i == numItems - 1) {
63 int nBytes = buffer.Length() % itemSize;
64 if(nBytes == 1) value32 &= 0xffu;
65 else if(nBytes == 2) value32 &= 0xffffu;
66 else if(nBytes == 3) value32 &= 0xffffffu;
70 v.push_back(static_cast<unsigned long>(value32));
77 theSeed =
trand_->GetSeed();
84 theSeed =
trand_->GetSeed();
99 if(v.empty())
return false;
100 if(v[0] != CLHEP::engineIDulong<TRandomAdaptor>())
return false;
101 int32_t numItems = v.size()-1;
103 int32_t itemSize =
sizeof(uint32_t);
104 TBufferFile buffer(TBuffer::kRead, numItems * itemSize + 1024);
105 char* bufferPtr = buffer.Buffer();
106 for(int32_t
i = 0;
i < numItems; ++
i) {
108 *
reinterpret_cast<uint32_t*
>(bufferPtr +
i * itemSize) = static_cast<uint32_t>(v[
i+1] & 0xffffffff);
124 std::ostringstream sstr;
125 sstr <<
"Unimplemented Feature: " << errortext <<
'\n';
std::vector< unsigned long > put() const
void setSeed(long seed, int)
virtual std::istream & getState(std::istream &is)
virtual std::istream & get(std::istream &is)
void setSeeds(long const *seeds, int)
virtual ~TRandomAdaptor()
void Grumble(std::string const &errortext) const