159 #include "TDirectory.h" 195 if (prob < 0 || prob > 1)
return 0;
197 for (Int_t i=0;i<ntot;i++) {
198 if (
Rndm() > prob)
continue;
209 Double_t rval, displ;
258 const Double_t kC1 = 1.448242853;
259 const Double_t kC2 = 3.307147487;
260 const Double_t kC3 = 1.46754004;
261 const Double_t kD1 = 1.036467755;
262 const Double_t kD2 = 5.295844968;
263 const Double_t kD3 = 3.631288474;
264 const Double_t kHm = 0.483941449;
265 const Double_t kZm = 0.107981933;
266 const Double_t kHp = 4.132731354;
267 const Double_t kZp = 18.52161694;
268 const Double_t kPhln = 0.4515827053;
269 const Double_t kHm1 = 0.516058551;
270 const Double_t kHp1 = 3.132731354;
271 const Double_t kHzm = 0.375959516;
272 const Double_t kHzmp = 0.591923442;
275 const Double_t kAs = 0.8853395638;
276 const Double_t kBs = 0.2452635696;
277 const Double_t kCs = 0.2770276848;
278 const Double_t kB = 0.5029324303;
279 const Double_t kX0 = 0.4571828819;
280 const Double_t kYm = 0.187308492 ;
281 const Double_t kS = 0.7270572718 ;
282 const Double_t kT = 0.03895759111;
291 result = kHp*y-kHp1;
break; }
295 result = (rn>0) ? (1+rn) : (-1+rn);
302 z = (rn>0) ? 2-rn : -2-rn;
303 if ((kC1-y)*(kC3+TMath::Abs(z))<kC2) {
307 if ((y+kD1)*(kD3+
x)<kD2) {
308 result = rn;
break; }
309 else if (kHzmp-y<
exp(-(z*z+kPhln)/2)) {
311 else if (y+kHzm<
exp(-(x+kPhln)/2)) {
312 result = rn;
break; }
327 if ((y-kAs+x)*(kCs+
x)+kBs<0) {
328 result = rn;
break; }
330 if (rn*rn<4*(kB-
log(x))) {
331 result = rn;
break; }
335 return mean + sigma * result;
344 ui = (UInt_t)(imax*
Rndm());
363 if (sigma <= 0)
return 0;
386 if (mean <= 0)
return 0;
394 if (pir <= expmean)
break;
399 else if (mean < 1E9) {
401 Double_t sq, alxm, g;
415 t = 0.9*(1.0 + y*
y)*
TMath::Exp(em*alxm - TMath::LnGamma(em + 1.0) - g);
416 }
while(
Rndm() > t );
418 return static_cast<Int_t
> (
em);
438 if (mean <= 0)
return 0;
446 if (pir <= expmean)
break;
448 return static_cast<Double_t
>(n);
451 else if (mean < 1E9) {
453 Double_t sq, alxm, g;
467 t = 0.9*(1.0 + y*
y)*
TMath::Exp(em*alxm - TMath::LnGamma(em + 1.0) - g);
468 }
while(
Rndm() > t );
487 x = z * 6.28318530717958623;
502 x = z * 6.28318530717958623;
513 if (!gDirectory)
return;
514 char *fntmp = gSystem->ExpandPathName(filename);
515 TDirectory *file = (TDirectory*)gROOT->ProcessLine(Form(
"TFile::Open(\"%s\");",fntmp));
517 if(file && file->GetFile()) {
518 gDirectory->ReadTObject(
this,GetName());
535 #ifdef OLD_TRANDOM_IMPL 536 const Double_t kCONS = 4.6566128730774E-10;
537 const Int_t kMASK24 = 2147483392;
540 UInt_t jy = (
fSeed&kMASK24);
541 if (jy)
return kCONS*jy;
546 const Double_t kCONS = 4.6566128730774E-10;
547 fSeed = (1103515245 *
fSeed + 12345) & 0x7fffffffUL;
558 const Double_t kCONS = 4.6566128730774E-10;
561 fSeed = (1103515245 *
fSeed + 12345) & 0x7fffffffUL;
571 const Double_t kCONS = 4.6566128730774E-10;
574 fSeed = (1103515245 *
fSeed + 12345) & 0x7fffffffUL;
575 if (
fSeed) {array[i] = Float_t(kCONS*
fSeed); i++;}
595 fSeed = UInt_t(uuid[3])*16777216 + UInt_t(uuid[2])*65536 + UInt_t(uuid[1])*256 + UInt_t(uuid[0]);
611 Double_t a=0,
b=0,r2=1;
617 z = r* ( -1. + 8.0 * r2 );
629 Double_t ans =
Rndm();
638 Double_t ans=
Rndm();
639 return x1 + (x2-x1)*ans;
647 if (!gDirectory)
return;
648 char *fntmp = gSystem->ExpandPathName(filename);
649 TDirectory *file = (TDirectory*)gROOT->ProcessLine(Form(
"TFile::Open(\"%s\",\"recreate\");",fntmp));
651 if(file && file->GetFile()) {
652 gDirectory->WriteTObject(
this,GetName());
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
virtual Double_t PoissonD(Double_t mean)
Generates a random number according to a Poisson law.
Double_t Floor(Double_t x)
virtual Int_t Binomial(Int_t ntot, Double_t prob)
Generates a random integer N according to the binomial law.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
constexpr Double_t TwoPi()
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
virtual ~TRandom()
Default destructor.
you should not use this method at all Int_t y
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
you should not use this method at all Int_t Int_t Double_t Double_t em
This is the base class for the ROOT Random number generators.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
virtual Double_t Rndm()
Machine independent random number generator.
TRandom(UInt_t seed=65539)
Default constructor. For seed see SetSeed().
virtual void WriteRandom(const char *filename) const
Writes random generator status to filename.
R__EXTERN TRandom * gRandom
virtual void Circle(Double_t &x, Double_t &y, Double_t r)
Generates random vectors, uniformly distributed over a circle of given radius.
* x
Deprecated and error prone model selection interface.
virtual void ReadRandom(const char *filename)
Reads saved random generator status from filename.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual Double_t BreitWigner(Double_t mean=0, Double_t gamma=1)
Return a number distributed following a BreitWigner function with mean and gamma. ...
virtual void Sphere(Double_t &x, Double_t &y, Double_t &z, Double_t r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
you should not use this method at all Int_t Int_t z
double landau_quantile(double z, double xi=1)
Inverse ( ) of the cumulative distribution function of the lower tail of the Landau distribution (lan...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Double_t Sqrt(Double_t x)
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
constexpr Double_t PiOver2()
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.