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

#include <PhotosDebugRandom.h>

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

Static Public Member Functions

static void saveState ()
 
static void restoreState ()
 
static void setState (int i, int j, double c, double list[97])
 
static void setSaveState (int i, int j, double c, double list[97])
 
static void print ()
 

Static Private Member Functions

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

Static Private Attributes

static int i97_saved = 0
 
static int j97_saved = 0
 
static double uran_saved [97] = { 0 }
 
static double cran_saved = 0
 
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 25 of file PhotosDebugRandom.h.

Member Function Documentation

void PhotosRandom::initialize ( )
staticinherited

Definition at line 45 of file PhotosRandom.cxx.

References Photospp::Log::Debug(), i, Photospp::PhotosRandom::init, Photospp::PhotosRandom::iseed, T, and Photospp::PhotosRandom::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 ( )
staticinherited
void PhotosDebugRandom::print ( )
static

Definition at line 48 of file PhotosDebugRandom.cxx.

References Photospp::PhotosRandom::cran, i, Photospp::PhotosRandom::i97, Photospp::Log::Info(), Photospp::PhotosRandom::j97, Photospp::Log::RedirectOutput(), Photospp::Log::RevertOutput(), and Photospp::PhotosRandom::uran.

49 {
50  int coutPrec = cout.precision(18);
51  ios_base::fmtflags flags = cout.setf(ios_base::floatfield);
52 
54 
55  cout<<"double uran_state[97] = { ";
56  for(int i=0;i<96;i++) cout<<uran[i]<<", ";
57  cout<<uran[96]<<" };"<<endl<<endl;
58  cout<<"PhotosDebugRandom::setState( "<<i97<<", "<<j97<<", "<<cran<<", uran_state );"<<endl;
59 
61 
62  // Revert output stream flags and precision
63  cout.precision(coutPrec);
64  cout.flags (flags);
65 }
Int_t i
Definition: run_full.C:25
static ostream & Info(bool count=true)
Definition: Log.cxx:38
static double cran
Definition: PhotosRandom.h:40
static void RevertOutput()
Definition: Log.h:90
static double uran[97]
Definition: PhotosRandom.h:39
static void RedirectOutput(void(*func)(), ostream &where=*out)
Definition: Log.cxx:90
static double Photospp::PhotosRandom::randomReal ( )
staticinherited
double PhotosRandom::randomReal ( )
staticinherited

Definition at line 91 of file PhotosRandom.cxx.

References Photospp::PhotosRandom::cdran, Photospp::PhotosRandom::cmran, Photospp::PhotosRandom::cran, Photospp::Log::Fatal(), Photospp::PhotosRandom::i97, Photospp::PhotosRandom::init, Photospp::PhotosRandom::j97, and Photospp::PhotosRandom::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
void PhotosDebugRandom::restoreState ( )
static
void PhotosDebugRandom::saveState ( )
static
void PhotosDebugRandom::setSaveState ( int  i,
int  j,
double  c,
double  list[97] 
)
static

Definition at line 40 of file PhotosDebugRandom.cxx.

References c, cran_saved, i, i97_saved, j97_saved, and uran_saved.

41 {
42  i97_saved=i;
43  j97_saved=j;
44  cran_saved=c;
45  for(int i=0;i<97;i++) uran_saved[i]=list[i];
46 }
Int_t i
Definition: run_full.C:25
static void Photospp::PhotosRandom::setSeed ( int  s1,
int  s2 
)
staticinherited
void PhotosRandom::setSeed ( int  s1,
int  s2 
)
staticinherited

Definition at line 25 of file PhotosRandom.cxx.

References Photospp::Log::Fatal(), and Photospp::PhotosRandom::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)
void PhotosDebugRandom::setState ( int  i,
int  j,
double  c,
double  list[97] 
)
static

Definition at line 32 of file PhotosDebugRandom.cxx.

References c, Photospp::PhotosRandom::cran, i, Photospp::PhotosRandom::i97, Photospp::PhotosRandom::j97, and Photospp::PhotosRandom::uran.

33 {
34  i97=i;
35  j97=j;
36  cran=c;
37  for(int i=0;i<97;i++) uran[i]=list[i];
38 }
Int_t i
Definition: run_full.C:25
static double cran
Definition: PhotosRandom.h:40
static double uran[97]
Definition: PhotosRandom.h:39

Member Data Documentation

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

Definition at line 41 of file PhotosRandom.h.

Referenced by Photospp::PhotosRandom::randomReal().

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

Definition at line 42 of file PhotosRandom.h.

Referenced by Photospp::PhotosRandom::randomReal().

static double PhotosRandom::cran = 362436.0 /16777216.0
staticprotectedinherited
double PhotosDebugRandom::cran_saved = 0
staticprivate

Definition at line 47 of file PhotosDebugRandom.h.

Referenced by restoreState(), saveState(), and setSaveState().

static int PhotosRandom::i97 = 96
staticprotectedinherited
int PhotosDebugRandom::i97_saved = 0
staticprivate

Definition at line 44 of file PhotosDebugRandom.h.

Referenced by restoreState(), saveState(), and setSaveState().

static bool PhotosRandom::init = false
staticprotectedinherited
static int PhotosRandom::iseed = { 1802, 9373 }
staticprotectedinherited
static int PhotosRandom::j97 = 32
staticprotectedinherited
int PhotosDebugRandom::j97_saved = 0
staticprivate

Definition at line 45 of file PhotosDebugRandom.h.

Referenced by restoreState(), saveState(), and setSaveState().

static double PhotosRandom::uran = { 0.0 }
staticprotectedinherited
double PhotosDebugRandom::uran_saved = { 0 }
staticprivate

Definition at line 46 of file PhotosDebugRandom.h.

Referenced by restoreState(), saveState(), and setSaveState().


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