FairRoot/PandaRoot
Static Public Member Functions | Static Protected Attributes | List of all members
Photospp::PhotosRandom Class Reference

#include <PhotosRandom.h>

Inheritance diagram for Photospp::PhotosRandom:
Photospp::PhotosDebugRandom

Static Public Member Functions

static void setSeed (int s1, int s2)
 
static void initialize ()
 
static double randomReal ()
 
static void setSeed (int s1, int s2)
 
static void initialize ()
 
static double randomReal ()
 

Static Protected Attributes

static bool init = false
 
static int iseed [2] = { 1802, 9373 }
 
static int i97 = 96
 
static int j97 = 32
 
static double uran [97] = { 0.0 }
 
static double cran = 362436.0 /16777216.0
 
static const double cdran = 7654321.0 /16777216.0
 
static const double cmran = 16777213.0/16777216.0
 

Detailed Description

Definition at line 20 of file PhotosRandom.h.

Member Function Documentation

void PhotosRandom::initialize ( )
static

Definition at line 45 of file PhotosRandom.cxx.

References Photospp::Log::Debug(), i, init, iseed, T, and uran.

Referenced by Photospp::Photos::initialize().

46 {
47  long IS1,IS2,IS3,IS4,IS5;
48  double S,T;
49 
50 // Calculate Marsaglia and Zaman seeds (by F. James)
51  IS1=(iseed[0]/177)%177+2;
52  IS2= iseed[0]%177+2;
53  IS3=(iseed[1]/169)%178+1;
54  IS4= iseed[1]%169;
55  for(int i=0;i<97;i++)
56  {
57  S=0.0;
58  T=0.5;
59  for(int j=0;j<24;j++)
60  {
61  IS5=( ((IS1*IS2)%179)*IS3 )%179;
62  IS1=IS2;
63  IS2=IS3;
64  IS3=IS5;
65  IS4=(53*IS4+1)%169;
66  if( (IS4*IS5)%64>=32) S=S+T;
67  T=0.5*T;
68  }
69  uran[i]=S;
70  }
71  init=true;
72  Log::Debug(0)<<"PhotosRandom::inititalize(): seed: "<<iseed[0]<<", "<<iseed[1]<<std::endl;
73 }
Int_t i
Definition: run_full.C:25
TTree * T
Definition: anaLmdReco.C:32
static ostream & Debug(unsigned short int code=0, bool count=true)
Definition: Log.cxx:30
static int iseed[2]
Definition: PhotosRandom.h:36
static double uran[97]
Definition: PhotosRandom.h:39
static void Photospp::PhotosRandom::initialize ( )
static
static double Photospp::PhotosRandom::randomReal ( )
static
double PhotosRandom::randomReal ( )
static

Definition at line 91 of file PhotosRandom.cxx.

References cdran, cmran, cran, Photospp::Log::Fatal(), i97, init, j97, and uran.

Referenced by Photospp::Photos::setRandomGenerator().

92 {
93  if(!init) Log::Fatal("PhotosRandom::randomReal(): generator not initialized",1);
94  double ret=0.0;
95  while(true)
96  {
97  ret = uran[i97]-uran[j97];
98  if(ret<0.0) ret+=1.;
99  uran[i97]=ret;
100  i97--;
101  if(i97<0) i97=96;
102  j97--;
103  if(j97<0) j97=96;
104  cran-=cdran;
105  if(cran<0.0) cran+=cmran;
106  ret-=cran;
107  if(ret<0.0) ret+=1.0;
108  if(ret>0.0) break;
109  }
110  return ret;
111 }
static const double cmran
Definition: PhotosRandom.h:42
static const double cdran
Definition: PhotosRandom.h:41
static double cran
Definition: PhotosRandom.h:40
static void Fatal(string text, unsigned short int code=0)
static double uran[97]
Definition: PhotosRandom.h:39
static void Photospp::PhotosRandom::setSeed ( int  s1,
int  s2 
)
static
void PhotosRandom::setSeed ( int  s1,
int  s2 
)
static

Definition at line 25 of file PhotosRandom.cxx.

References Photospp::Log::Fatal(), and iseed.

Referenced by Photospp::Photos::setSeed().

26 {
27  if(s1<0 || s1>31327) Log::Fatal("PhotosRandom::setSeed(): Seed(1) out of range [0,31327]",8);
28  if(s2<0 || s2>30080) Log::Fatal("PhotosRandom::setSeed(): Seed(2) out of range [0,30080]",9);
29  iseed[0]=s1;
30  iseed[1]=s2;
31 }
static int iseed[2]
Definition: PhotosRandom.h:36
static void Fatal(string text, unsigned short int code=0)

Member Data Documentation

static const double PhotosRandom::cdran = 7654321.0 /16777216.0
staticprotected

Definition at line 41 of file PhotosRandom.h.

Referenced by randomReal().

static const double PhotosRandom::cmran = 16777213.0/16777216.0
staticprotected

Definition at line 42 of file PhotosRandom.h.

Referenced by randomReal().

static double PhotosRandom::cran = 362436.0 /16777216.0
staticprotected
static int PhotosRandom::i97 = 96
staticprotected
static bool PhotosRandom::init = false
staticprotected

Definition at line 35 of file PhotosRandom.h.

Referenced by initialize(), and randomReal().

static int PhotosRandom::iseed = { 1802, 9373 }
staticprotected

Definition at line 36 of file PhotosRandom.h.

Referenced by initialize(), and setSeed().

static int PhotosRandom::j97 = 32
staticprotected
static double PhotosRandom::uran = { 0.0 }
staticprotected

The documentation for this class was generated from the following files: