62 static inline HepDouble shoot();
63 static inline HepDouble shoot( HepDouble width );
64 static inline HepDouble shoot( HepDouble a, HepDouble b );
66 static inline long shootInt(
long n );
67 static inline long shootInt(
long m,
long n );
69 static inline HepInt shootBit();
71 static inline void shootArray (
const HepInt size, HepDouble* vect );
72 #ifndef ST_NO_TEMPLATE_DEF_ARGS
73 static inline void shootArray (vector<HepDouble>&);
75 static inline void shootArray (vector<HepDouble, allocator<HepDouble> >&);
77 static void shootArray (
const HepInt size, HepDouble* vect,
78 HepDouble lx, HepDouble dx );
79 #ifndef ST_NO_TEMPLATE_DEF_ARGS
80 static void shootArray ( vector<HepDouble>&, HepDouble, HepDouble );
82 static void shootArray ( vector<HepDouble, allocator<HepDouble> >&,
83 HepDouble, HepDouble );
90 static inline HepDouble shoot(
HepRandomEngine* anEngine, HepDouble width );
93 HepDouble a, HepDouble b );
96 static inline long shootInt(
HepRandomEngine* anEngine,
long m,
long n );
101 const HepInt size, HepDouble* vect );
102 #ifndef ST_NO_TEMPLATE_DEF_ARGS
103 static inline void shootArray (
HepRandomEngine*, vector<HepDouble>& );
105 static inline void shootArray (
HepRandomEngine*, vector<HepDouble,allocator<HepDouble> >& );
109 const HepInt size, HepDouble* vect,
110 HepDouble lx, HepDouble dx );
111 #ifndef ST_NO_TEMPLATE_DEF_ARGS
114 HepDouble, HepDouble );
117 vector<HepDouble,allocator<HepDouble> >&,
118 HepDouble, HepDouble );
123 inline HepDouble fire();
125 inline HepDouble fire( HepDouble width );
127 inline HepDouble fire( HepDouble a, HepDouble b );
129 inline long fireInt(
long n );
131 inline long fireInt(
long m,
long n );
133 inline HepInt fireBit();
135 inline void fireArray (
const HepInt size, HepDouble* vect);
136 #ifndef ST_NO_TEMPLATE_DEF_ARGS
137 inline void fireArray (vector<HepDouble>&);
139 inline void fireArray (vector<HepDouble,allocator<HepDouble> >&);
142 void fireArray (
const HepInt size, HepDouble* vect,
143 HepDouble lx, HepDouble dx);
144 #ifndef ST_NO_TEMPLATE_DEF_ARGS
145 void fireArray (vector<HepDouble>&, HepDouble, HepDouble);
147 void fireArray (vector<HepDouble,allocator<HepDouble> >&, HepDouble, HepDouble);
149 HepDouble operator()();
157 inline void fireBits();
158 static inline void shootBits();
172 HepBoolean deleteEngine;
174 unsigned long randomInt;
175 unsigned long firstUnusedBit;
177 static const HepInt MSBBits;
178 static const unsigned long MSB;
180 static unsigned long staticRandomInt;
181 static unsigned long staticFirstUnusedBit;
185 : localEngine(&anEngine), deleteEngine(false), firstUnusedBit(0) {}
188 : localEngine(anEngine), deleteEngine(true), firstUnusedBit(0) {}
190 inline HepDouble RandFlat::shoot() {
191 return HepRandom::getTheGenerator()->flat();
194 inline HepDouble RandFlat::shoot(HepDouble a, HepDouble b) {
195 return (b-a)* shoot() + a;
198 inline HepDouble RandFlat::shoot(HepDouble width) {
199 return width * shoot();
202 inline long RandFlat::shootInt(
long n) {
203 return long(shoot()*HepDouble(n));
206 inline long RandFlat::shootInt(
long m,
long n) {
207 return long(shoot()*HepDouble(n-m)) + m;
210 inline void RandFlat::shootArray(
const HepInt size, HepDouble* vect) {
211 HepRandom::getTheGenerator()->flatArray(size,vect);
214 #ifndef ST_NO_TEMPLATE_DEF_ARGS
215 inline void RandFlat::shootArray(vector<HepDouble>& vec)
217 inline void RandFlat::shootArray(vector<HepDouble,allocator<HepDouble> >& vec)
220 HepRandom::getTheGenerator()->flatArray(vec);
223 inline void RandFlat::shootBits() {
224 const HepDouble factor= 2.0*MSB;
225 staticFirstUnusedBit= MSB;
226 staticRandomInt= (
unsigned long)(factor*shoot());
229 inline HepInt RandFlat::shootBit() {
230 if (staticFirstUnusedBit==0)
232 unsigned long temp= staticFirstUnusedBit&staticRandomInt;
233 staticFirstUnusedBit>>= 1;
240 return anEngine->flat();
245 HepDouble a, HepDouble b) {
246 return (b-a)* anEngine->flat() + a;
251 return width * anEngine->flat();
256 return long(anEngine->flat()*HepDouble(n));
261 return long(HepDouble(n-m)*anEngine->flat()) + m;
265 const HepInt size, HepDouble* vect) {
266 anEngine->flatArray(size,vect);
269 #ifndef ST_NO_TEMPLATE_DEF_ARGS
271 vector<HepDouble>& vec)
274 vector<HepDouble,allocator<HepDouble> >& vec)
277 anEngine->flatArray(vec);
281 const HepDouble factor= 2.0*MSB;
282 staticFirstUnusedBit= MSB;
283 staticRandomInt= (
unsigned long)(factor*shoot(engine));
287 if (staticFirstUnusedBit==0)
289 unsigned long temp= staticFirstUnusedBit&staticRandomInt;
290 staticFirstUnusedBit>>= 1;
296 inline HepDouble RandFlat::fire() {
297 return localEngine->flat();
300 inline HepDouble RandFlat::fire(HepDouble a, HepDouble b) {
301 return (b-a)* fire() + a;
304 inline HepDouble RandFlat::fire(HepDouble width) {
305 return width * fire();
308 inline long RandFlat::fireInt(
long n) {
309 return long(fire()*HepDouble(n));
312 inline long RandFlat::fireInt(
long m,
long n) {
313 return long(fire()*HepDouble(n-m)) + m;
316 inline void RandFlat::fireArray(
const HepInt size, HepDouble* vect) {
317 flatArray(localEngine,size,vect);
320 #ifndef ST_NO_TEMPLATE_DEF_ARGS
321 inline void RandFlat::fireArray(vector<HepDouble>&vec)
323 inline void RandFlat::fireArray(vector<HepDouble,allocator<HepDouble> >&vec)
326 flatArray(localEngine,vec);
329 inline void RandFlat::fireBits() {
330 const HepDouble factor= 2.0*MSB;
332 randomInt= (
unsigned long)(factor*fire());
335 inline HepInt RandFlat::fireBit() {
336 if (firstUnusedBit==0)
338 unsigned long temp= firstUnusedBit&randomInt;