Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CLHEP::RandFlat Class Reference

#include <RandFlat.h>

Inheritance diagram for CLHEP::RandFlat:
Collaboration diagram for CLHEP::RandFlat:

Public Member Functions

 RandFlat (HepRandomEngine &anEngine)
 
 RandFlat (HepRandomEngine &anEngine, double width)
 
 RandFlat (HepRandomEngine &anEngine, double a, double b)
 
 RandFlat (HepRandomEngine *anEngine)
 
 RandFlat (HepRandomEngine *anEngine, double width)
 
 RandFlat (HepRandomEngine *anEngine, double a, double b)
 
virtual ~RandFlat ()
 
double fire ()
 
double fire (double width)
 
double fire (double a, double b)
 
long fireInt (long n)
 
long fireInt (long a1, long n)
 
int fireBit ()
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double lx, double dx)
 
double operator() ()
 
double operator() (double width)
 
double operator() (double a, double b)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
std::string name () const
 
HepRandomEngineengine ()
 
- Public Member Functions inherited from CLHEP::HepRandom
 HepRandom ()
 
 HepRandom (long seed)
 
 HepRandom (HepRandomEngine &algorithm)
 
 HepRandom (HepRandomEngine *algorithm)
 
virtual ~HepRandom ()
 
double flat ()
 
void flatArray (const int size, double *vect)
 
double flat (HepRandomEngine *theNewEngine)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, double *vect)
 

Static Public Member Functions

static double shoot ()
 
static double shoot (double width)
 
static double shoot (double a, double b)
 
static long shootInt (long n)
 
static long shootInt (long a1, long n)
 
static int shootBit ()
 
static void shootArray (const int size, double *vect)
 
static void shootArray (const int size, double *vect, double lx, double dx)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double width)
 
static double shoot (HepRandomEngine *anEngine, double a, double b)
 
static long shootInt (HepRandomEngine *anEngine, long n)
 
static long shootInt (HepRandomEngine *anEngine, long a1, long n)
 
static int shootBit (HepRandomEngine *)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double lx, double dx)
 
static std::string distributionName ()
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
- Static Public Member Functions inherited from CLHEP::HepRandom
static void setTheSeed (long seed, int lux=3)
 
static long getTheSeed ()
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static const long * getTheSeeds ()
 
static void getTheTableSeeds (long *seeds, int index)
 
static HepRandomgetTheGenerator ()
 
static void setTheEngine (HepRandomEngine *theNewEngine)
 
static HepRandomEnginegetTheEngine ()
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
static std::ostream & saveStaticRandomStates (std::ostream &os)
 
static std::istream & restoreStaticRandomStates (std::istream &is)
 
static void showEngineStatus ()
 
static int createInstance ()
 
static std::string distributionName ()
 

Additional Inherited Members

- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Constructor & Destructor Documentation

CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine)
inline
CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine,
double  width 
)
inline
CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine,
double  a,
double  b 
)
inline
CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine)
inline
CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine,
double  width 
)
inline
CLHEP::RandFlat::RandFlat ( HepRandomEngine anEngine,
double  a,
double  b 
)
inline
CLHEP::RandFlat::~RandFlat ( )
virtual

Definition at line 44 of file RandFlat.cc.

44  {
45 }

Member Function Documentation

static std::string CLHEP::RandFlat::distributionName ( )
inlinestatic

Definition at line 137 of file RandFlat.h.

137 {return "RandFlat";}

Here is the caller graph for this function:

HepRandomEngine & CLHEP::RandFlat::engine ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 42 of file RandFlat.cc.

42 {return *localEngine;}
double CLHEP::RandFlat::fire ( )
inline

Here is the caller graph for this function:

double CLHEP::RandFlat::fire ( double  width)
inline
double CLHEP::RandFlat::fire ( double  a,
double  b 
)
inline
void CLHEP::RandFlat::fireArray ( const int  size,
double *  vect 
)

Definition at line 86 of file RandFlat.cc.

87 {
88  int i;
89 
90  for (i=0; i<size; ++i)
91  vect[i] = fire( defaultA, defaultB );
92 }

Here is the call graph for this function:

void CLHEP::RandFlat::fireArray ( const int  size,
double *  vect,
double  lx,
double  dx 
)

Definition at line 94 of file RandFlat.cc.

96 {
97  int i;
98 
99  for (i=0; i<size; ++i)
100  vect[i] = fire( lx, dx );
101 }

Here is the call graph for this function:

int CLHEP::RandFlat::fireBit ( )
inline
long CLHEP::RandFlat::fireInt ( long  n)
inline
long CLHEP::RandFlat::fireInt ( long  a1,
long  n 
)
inline
std::istream & CLHEP::RandFlat::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 171 of file RandFlat.cc.

171  {
172  std::string inName;
173  is >> inName;
174  if (inName != name()) {
175  is.clear(std::ios::badbit | is.rdstate());
176  std::cerr << "Mismatch when expecting to read state of a "
177  << name() << " distribution\n"
178  << "Name found was " << inName
179  << "\nistream is left in the badbit state\n";
180  return is;
181  }
182  if (possibleKeywordInput(is, "Uvec", randomInt)) {
183  std::vector<unsigned long> t(2);
184  is >> randomInt >> firstUnusedBit;
185  is >> defaultWidth >>t[0]>>t[1]; defaultWidth = DoubConv::longs2double(t);
186  is >> defaultA >> t[0] >> t[1]; defaultA = DoubConv::longs2double(t);
187  is >> defaultB >> t[0] >> t[1]; defaultB = DoubConv::longs2double(t);
188  if (!is) {
189  is.clear(std::ios::badbit | is.rdstate());
190  std::cerr << "\nRandFlat input failed"
191  << "\nInput stream is probably mispositioned now." << std::endl;
192  return is;
193  }
194  return is;
195  }
196  // is >> randomInt encompassed by possibleKeywordInput
197  is >> firstUnusedBit;
198  is >> defaultWidth >> defaultA >> defaultB;
199  return is;
200 }
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:167
std::string name() const
Definition: RandFlat.cc:41
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:114

Here is the call graph for this function:

Here is the caller graph for this function:

std::string CLHEP::RandFlat::name ( ) const
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 41 of file RandFlat.cc.

41 {return "RandFlat";}

Here is the caller graph for this function:

double CLHEP::RandFlat::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 47 of file RandFlat.cc.

47  {
48  return fire( defaultA, defaultB );
49 }

Here is the call graph for this function:

double CLHEP::RandFlat::operator() ( double  width)

Definition at line 51 of file RandFlat.cc.

51  {
52  return fire( w );
53 }

Here is the call graph for this function:

double CLHEP::RandFlat::operator() ( double  a,
double  b 
)

Definition at line 55 of file RandFlat.cc.

55  {
56  return fire( a, b );
57 }
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
tuple b
Definition: test.py:12

Here is the call graph for this function:

std::ostream & CLHEP::RandFlat::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 155 of file RandFlat.cc.

155  {
156  int pr=os.precision(20);
157  std::vector<unsigned long> t(2);
158  os << " " << name() << "\n";
159  os << "Uvec" << "\n";
160  os << randomInt << " " << firstUnusedBit << "\n";
161  t = DoubConv::dto2longs(defaultWidth);
162  os << defaultWidth << " " << t[0] << " " << t[1] << "\n";
163  t = DoubConv::dto2longs(defaultA);
164  os << defaultA << " " << t[0] << " " << t[1] << "\n";
165  t = DoubConv::dto2longs(defaultB);
166  os << defaultB << " " << t[0] << " " << t[1] << "\n";
167  os.precision(pr);
168  return os;
169 }
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:98
std::string name() const
Definition: RandFlat.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

std::istream & CLHEP::RandFlat::restoreDistState ( std::istream &  is)
static

Definition at line 211 of file RandFlat.cc.

211  {
212  std::string inName;
213  is >> inName;
214  if (inName != distributionName()) {
215  is.clear(std::ios::badbit | is.rdstate());
216  std::cerr << "Mismatch when expecting to read static state of a "
217  << distributionName() << " distribution\n"
218  << "Name found was " << inName
219  << "\nistream is left in the badbit state\n";
220  return is;
221  }
222  std::string keyword;
223  std::string c1;
224  std::string c2;
225  is >> keyword;
226  if (keyword!="RANDFLAT") {
227  is.clear(std::ios::badbit | is.rdstate());
228  std::cerr << "Mismatch when expecting to read RANDFLAT bit cache info: "
229  << keyword << "\n";
230  return is;
231  }
232  is >> c1 >> staticRandomInt >> c2 >> staticFirstUnusedBit;
233  return is;
234 }
static c2_factory< G4double > c2
static std::string distributionName()
Definition: RandFlat.h:137
tuple c1
Definition: plottest35.py:14

Here is the call graph for this function:

Here is the caller graph for this function:

void CLHEP::RandFlat::restoreEngineStatus ( const char  filename[] = "Config.conf")
static

Definition at line 118 of file RandFlat.cc.

118  {
119 
120  // First restore the engine status just like the base class would do:
121  getTheEngine()->restoreStatus( filename );
122 
123  // Now find the line describing the cached data:
124 
125  std::ifstream infile ( filename, std::ios::in );
126  if (!infile) return;
127  char inputword[] = "NO_KEYWORD "; // leaves room for 14 characters plus \0
128  while (true) {
129  infile.width(13);
130  infile >> inputword;
131  if (strcmp(inputword,"RANDFLAT")==0) break;
132  if (infile.eof()) break;
133  // If the file ends without the RANDFLAT line, that means this
134  // was a file produced by an earlier version of RandFlat. We will
135  // replicate the old behavior in that case: staticFirstUnusedBit
136  // and staticRandomInt retain their existing values.
137  }
138 
139  // Then read and use the caching info:
140 
141  if (strcmp(inputword,"RANDFLAT")==0) {
142  char setword[40]; // the longest, staticFirstUnusedBit: has length 21
143  infile.width(39);
144  infile >> setword;
145  // setword should be staticRandomInt:
146  infile >> staticRandomInt;
147  infile.width(39);
148  infile >> setword;
149  // setword should be staticFirstUnusedBit:
150  infile >> staticFirstUnusedBit;
151  }
152 
153 } // restoreEngineStatus
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265
virtual void restoreStatus(const char filename[]="Config.conf")=0

Here is the call graph for this function:

std::istream & CLHEP::RandFlat::restoreFullState ( std::istream &  is)
static

Definition at line 242 of file RandFlat.cc.

242  {
244  restoreDistState(is);
245  return is;
246 }
static std::istream & restoreDistState(std::istream &is)
Definition: RandFlat.cc:211
static std::istream & restoreFullState(std::istream &is)
Definition: Random.cc:290

Here is the call graph for this function:

Here is the caller graph for this function:

std::ostream & CLHEP::RandFlat::saveDistState ( std::ostream &  os)
static

Definition at line 202 of file RandFlat.cc.

202  {
203  os << distributionName() << "\n";
204  int prec = os.precision(20);
205  os << "RANDFLAT staticRandomInt: " << staticRandomInt
206  << " staticFirstUnusedBit: " << staticFirstUnusedBit << "\n";
207  os.precision(prec);
208  return os;
209 }
static const double prec
Definition: RanecuEngine.cc:58
static std::string distributionName()
Definition: RandFlat.h:137

Here is the call graph for this function:

Here is the caller graph for this function:

void CLHEP::RandFlat::saveEngineStatus ( const char  filename[] = "Config.conf")
static

Definition at line 103 of file RandFlat.cc.

103  {
104 
105  // First save the engine status just like the base class would do:
106  getTheEngine()->saveStatus( filename );
107 
108  // Now append the cached random Int, and first unused bit:
109 
110  std::ofstream outfile ( filename, std::ios::app );
111 
112  outfile << "RANDFLAT staticRandomInt: " << staticRandomInt
113  << " staticFirstUnusedBit: " << staticFirstUnusedBit << "\n";
114 
115 } // saveEngineStatus
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265
tuple app
Definition: demo.py:189
virtual void saveStatus(const char filename[]="Config.conf") const =0

Here is the call graph for this function:

std::ostream & CLHEP::RandFlat::saveFullState ( std::ostream &  os)
static

Definition at line 236 of file RandFlat.cc.

236  {
238  saveDistState(os);
239  return os;
240 }
static std::ostream & saveDistState(std::ostream &os)
Definition: RandFlat.cc:202
static std::ostream & saveFullState(std::ostream &os)
Definition: Random.cc:285

Here is the call graph for this function:

Here is the caller graph for this function:

double CLHEP::RandFlat::shoot ( )
static

Definition at line 59 of file RandFlat.cc.

59  {
60  return HepRandom::getTheEngine()->flat();
61 }
virtual double flat()=0
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265

Here is the call graph for this function:

Here is the caller graph for this function:

static double CLHEP::RandFlat::shoot ( double  width)
inlinestatic
static double CLHEP::RandFlat::shoot ( double  a,
double  b 
)
inlinestatic
static double CLHEP::RandFlat::shoot ( HepRandomEngine anEngine)
inlinestatic
static double CLHEP::RandFlat::shoot ( HepRandomEngine anEngine,
double  width 
)
inlinestatic
static double CLHEP::RandFlat::shoot ( HepRandomEngine anEngine,
double  a,
double  b 
)
inlinestatic
void CLHEP::RandFlat::shootArray ( const int  size,
double *  vect 
)
static

Definition at line 63 of file RandFlat.cc.

63  {
64  HepRandom::getTheEngine()->flatArray(size,vect);
65 }
static HepRandomEngine * getTheEngine()
Definition: Random.cc:265
virtual void flatArray(const int size, double *vect)=0

Here is the call graph for this function:

void CLHEP::RandFlat::shootArray ( const int  size,
double *  vect,
double  lx,
double  dx 
)
static

Definition at line 67 of file RandFlat.cc.

69 {
70  int i;
71 
72  for (i=0; i<size; ++i)
73  vect[i] = shoot(lx,dx);
74 }
static double shoot()
Definition: RandFlat.cc:59

Here is the call graph for this function:

static void CLHEP::RandFlat::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect 
)
inlinestatic
void CLHEP::RandFlat::shootArray ( HepRandomEngine anEngine,
const int  size,
double *  vect,
double  lx,
double  dx 
)
static

Definition at line 76 of file RandFlat.cc.

79 {
80  int i;
81 
82  for (i=0; i<size; ++i)
83  vect[i] = shoot(anEngine,lx,dx);
84 }
static double shoot()
Definition: RandFlat.cc:59

Here is the call graph for this function:

static int CLHEP::RandFlat::shootBit ( )
inlinestatic
static int CLHEP::RandFlat::shootBit ( HepRandomEngine )
inlinestatic
static long CLHEP::RandFlat::shootInt ( long  n)
inlinestatic
static long CLHEP::RandFlat::shootInt ( long  a1,
long  n 
)
inlinestatic
static long CLHEP::RandFlat::shootInt ( HepRandomEngine anEngine,
long  n 
)
inlinestatic
static long CLHEP::RandFlat::shootInt ( HepRandomEngine anEngine,
long  a1,
long  n 
)
inlinestatic

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