X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=RALICE%2FAliRandom.cxx;h=d4864ecec5053ba55154a28db7c7f1e63dee660b;hb=d9dd3bc8219369006d5e5a2cbcad0c8359539322;hp=b1367e8f4b00499844c837d8d08b228ac1b28ed4;hpb=d88f97ccd1c218106504dbf4cbf5bc65038e2a78;p=u%2Fmrichter%2FAliRoot.git diff --git a/RALICE/AliRandom.cxx b/RALICE/AliRandom.cxx index b1367e8f4b0..d4864ecec50 100644 --- a/RALICE/AliRandom.cxx +++ b/RALICE/AliRandom.cxx @@ -1,10 +1,119 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +// $Id$ + +/////////////////////////////////////////////////////////////////////////// +// Class AliRandom +// Generate universal random numbers on all common machines. +// Available distributions : Uniform, Gaussian, Poisson and +// User defined function +// +// Features : +// ---------- +// 1) Period = 2**144 +// 2) Same sequence of 24-bit real numbers on all common machines +// +// Reference : +// ----------- +// G.Marsaglia and A.Zaman, FSU-SCRI-87-50, Florida State University, 1987. +// +// Coding example : +// ---------------- +// +// Float_t rndm; // Variable to hold a single random number +// const Int_t n=1000; +// Float_t rvec[n]; // Vector to hold n random numbers +// +// AliRandom r; // Create a Random object with default sequence +// +// rndm=r.Uniform(); // Provide a uniform random number in <0,1> +// Float_t a=3.; +// Float_t b=5.; +// rndm=r.Uniform(a,b); // Provide a uniform random number in +// r.Uniform(rvec,n); // Provide n uniform randoms in <0,1> in rvec +// r.Uniform(rvec,n,a,b); // Provide n uniform randoms in in rvec +// +// rndm=r.Gauss(); // Provide a Gaussian random number with +// // mean=0 and sigma=1 +// Float_t mean=25.; +// Float_t sigma=5.; +// rndm=r.Gauss(mean,sigma); // Provide a Gaussian random number +// // with specified mean and sigma +// r.Gauss(rvec,n); // n Gaussian randoms mean=0 sigma=1 +// r.Gauss(rvec,n,mean,sigma); // n Gaussian randoms with specified +// // mean and sigma +// +// rndm=r.Poisson(mean); // Provide a Poisson random number with +// // specified mean +// r.Poisson(rvec,nmean); // n Poisson randoms with specified mean +// +// Int_t seed=1837724 +// AliRandom p(seed); // Create a Random object with specified seed. +// // The sequence is started from scratch. +// Int_t cnt1=25; +// Int_t cnt2=8; +// AliRandom q(seed,cnt1,cnt2); // Create a Random object with specified seed +// // The sequence is started at the location +// // denoted by the counters cnt1 and cnt2. +// +// q.Data(); // Print the current seed, cnt1 and cnt2 values. +// q.GetSeed(); // Provide the current seed value. +// q.GetCnt1(); // Provide the current cnt1 value. +// q.GetCnt2(); // Provide the current cnt2 value. +// +// Float_t udist(Float_t x) // A user defined distribution +// { +// return x*x-4.*x; +// } +// +// Int_t nbins=100; +// q.SetUser(a,b,nbins,udist); // Initialise generator for udist distribution +// q.User(); // Provide a random number according to the udist distribution +// q.User(rvec,n); // Provide n randoms according to the udist distribution +// +// Float_t* x=new Float_t[nbins]; +// Float_t* y=new Float_t[nbins]; +// +// ... code to fill x[] and y[] .. +// +// AliRandom s; +// s.SetUser(x,y,nbins); // Initialise generator for (x[i],y[i]) distribution +// s.User(); // Provide a random number according to the user distribution +// s.User(rvec,n); // Provide n randoms according to the user distribution +// +// Notes : +// ------- +// 1) Allowed seed values : 0 <= seed <= 921350143 +// Default seed = 53310452 +// 2) To ensure a unique sequence for each run, one can automatically +// construct a seed value by e.g. using the date and time. +// 3) Using the rvec facility saves a lot of CPU time for large n values. +// +//--- Author: Nick van Eijndhoven 11-oct-1997 UU-SAP Utrecht +//- Modified: NvE $Date$ UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliRandom.h" +#include "Riostream.h" ClassImp(AliRandom) // Class implementation to enable ROOT I/O AliRandom::AliRandom() { -// Creation of an AliRandom object and default initialisation +// Creation of an AliRandom object and default initialisation. // // A seed is used to create the initial u[97] table. // This seed is converted into four startup parameters i j k and l @@ -191,25 +300,25 @@ void AliRandom::Unpack(Int_t seed,Int_t& i,Int_t& j,Int_t& k,Int_t& l) } } /////////////////////////////////////////////////////////////////////////// -Int_t AliRandom::GetSeed() +Int_t AliRandom::GetSeed() const { // Provide the current seed value return fSeed; } /////////////////////////////////////////////////////////////////////////// -Int_t AliRandom::GetCnt1() +Int_t AliRandom::GetCnt1() const { // Provide the current value of the counter cnt1 return fCnt1; } /////////////////////////////////////////////////////////////////////////// -Int_t AliRandom::GetCnt2() +Int_t AliRandom::GetCnt2() const { // Provide the current value of the counter cnt2 return fCnt2; } /////////////////////////////////////////////////////////////////////////// -void AliRandom::Info() +void AliRandom::Data() const { // Print the current seed, cnt1 and cnt2 values cout << " *Random* seed = " << fSeed