Geant4  10.02.p03
G4Pow Class Reference

#include <G4Pow.hh>

Collaboration diagram for G4Pow:

Public Member Functions

 ~G4Pow ()
 
G4double Z13 (G4int Z) const
 
G4double A13 (G4double A) const
 
G4double Z23 (G4int Z) const
 
G4double A23 (G4double A) const
 
G4double logZ (G4int Z) const
 
G4double logA (G4double A) const
 
G4double logX (G4double x) const
 
G4double log10Z (G4int Z) const
 
G4double log10A (G4double A) const
 
G4double expA (G4double A) const
 
G4double powZ (G4int Z, G4double y) const
 
G4double powA (G4double A, G4double y) const
 
G4double powN (G4double x, G4int n) const
 
G4double factorial (G4int Z) const
 
G4double logfactorial (G4int Z) const
 

Static Public Member Functions

static G4PowGetInstance ()
 

Private Member Functions

 G4Pow ()
 
G4double logBase (G4double x) const
 

Private Attributes

const G4double onethird
 
const G4int max2
 
G4double maxA
 
G4double maxA2
 
G4double maxAexp
 
G4DataVector ener
 
G4DataVector logen
 
G4DataVector pz13
 
G4DataVector lz
 
G4DataVector lz2
 
G4DataVector fexp
 
G4DataVector fact
 
G4DataVector logfact
 

Static Private Attributes

static G4PowfpInstance = 0
 

Detailed Description

Definition at line 56 of file G4Pow.hh.

Constructor & Destructor Documentation

◆ ~G4Pow()

G4Pow::~G4Pow ( )

Definition at line 123 of file G4Pow.cc.

124 {}

◆ G4Pow()

G4Pow::G4Pow ( )
private

Definition at line 67 of file G4Pow.cc.

68  : onethird(1.0/3.0), max2(5)
69 {
70 #ifdef G4MULTITHREADED
72  {
73  G4Exception ("G4Pow::G4Pow()", "InvalidSetup", FatalException,
74  "Attempt to instantiate G4Pow in worker thread!");
75  }
76 #endif
77  const G4int maxZ = 512;
78  const G4int maxZfact = 170;
79 
80  maxA = -0.6 + maxZ;
81  maxA2 = 1.25 + max2*0.2;
82  maxAexp = -0.76+ maxZfact*0.5;
83 
84  ener.resize(max2+1,1.0);
85  logen.resize(max2+1,0.0);
86  lz2.resize(max2+1,0.0);
87  pz13.resize(maxZ,0.0);
88  lz.resize(maxZ,0.0);
89  fexp.resize(maxZfact,0.0);
90  fact.resize(maxZfact,0.0);
91  logfact.resize(maxZ,0.0);
92 
93  G4double f = 1.0;
94  G4double logf = 0.0;
95  fact[0] = 1.0;
96  fexp[0] = 1.0;
97 
98  for(G4int i=1; i<=max2; ++i)
99  {
100  ener[i] = powN(500.,i);
101  logen[i]= G4Log(ener[i]);
102  lz2[i] = G4Log(1.0 + i*0.2);
103  }
104 
105  for(G4int i=1; i<maxZ; ++i)
106  {
107  G4double x = G4double(i);
108  pz13[i] = std::pow(x,onethird);
109  lz[i] = G4Log(x);
110  if(i < maxZfact)
111  {
112  f *= x;
113  fact[i] = f;
114  fexp[i] = G4Exp(0.5*i);
115  }
116  logf += lz[i];
117  logfact[i] = logf;
118  }
119 }
G4DataVector fact
Definition: G4Pow.hh:121
G4double maxAexp
Definition: G4Pow.hh:113
G4double powN(G4double x, G4int n) const
Definition: G4Pow.cc:128
const G4double onethird
Definition: G4Pow.hh:108
int G4int
Definition: G4Types.hh:78
G4double maxA2
Definition: G4Pow.hh:112
G4DataVector pz13
Definition: G4Pow.hh:117
G4DataVector logfact
Definition: G4Pow.hh:122
const G4int max2
Definition: G4Pow.hh:109
G4double maxA
Definition: G4Pow.hh:111
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool IsWorkerThread()
Definition: G4Threading.cc:135
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
G4DataVector fexp
Definition: G4Pow.hh:120
G4DataVector ener
Definition: G4Pow.hh:115
double G4double
Definition: G4Types.hh:76
G4DataVector logen
Definition: G4Pow.hh:116
G4DataVector lz2
Definition: G4Pow.hh:119
G4DataVector lz
Definition: G4Pow.hh:118
Here is the call graph for this function:

Member Function Documentation

◆ A13()

G4double G4Pow::A13 ( G4double  A) const
inline

Definition at line 132 of file G4Pow.hh.

133 {
134  G4double res = 0.0;
135  if(A > 0.0)
136  {
137  G4double a = (1.0 <= A) ? A : 1.0/A;
138  if(1.0 > A) { a = 1.0/A; }
139  if(a <= maxA)
140  {
141  G4int i = G4int(a + 0.5);
142  G4double x = (a/G4double(i) - 1.0)*onethird;
143  res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
144  if(1.0 > A) { res = 1.0/res; }
145  }
146  else
147  {
148  res = std::pow(A, onethird);
149  }
150  }
151  return res;
152 }
const G4double onethird
Definition: G4Pow.hh:108
int G4int
Definition: G4Types.hh:78
double A(double temperature)
G4DataVector pz13
Definition: G4Pow.hh:117
G4double maxA
Definition: G4Pow.hh:111
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ A23()

G4double G4Pow::A23 ( G4double  A) const
inline

Definition at line 160 of file G4Pow.hh.

161 {
162  G4double x = A13(A);
163  return x*x;
164 }
double A(double temperature)
G4double A13(G4double A) const
Definition: G4Pow.hh:132
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expA()

G4double G4Pow::expA ( G4double  A) const
inline

Definition at line 235 of file G4Pow.hh.

236 {
237  G4double res;
238  G4double a = (0.0 <= A) ? A : -A;
239 
240  if(a <= maxAexp)
241  {
242  G4int i = G4int(2*a + 0.5);
243  G4double x = a - i*0.5;
244  res = fexp[i]*(1.0 + x*(1.0 + 0.5*(1.0 + onethird*x)*x));
245  }
246  else
247  {
248  res = G4Exp(a);
249  }
250  if(0.0 > A) { res = 1.0/res; }
251  return res;
252 }
G4double maxAexp
Definition: G4Pow.hh:113
const G4double onethird
Definition: G4Pow.hh:108
int G4int
Definition: G4Types.hh:78
double A(double temperature)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
G4DataVector fexp
Definition: G4Pow.hh:120
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ factorial()

G4double G4Pow::factorial ( G4int  Z) const
inline

Definition at line 264 of file G4Pow.hh.

265 {
266  return fact[Z];
267 }
G4DataVector fact
Definition: G4Pow.hh:121
Float_t Z
Here is the caller graph for this function:

◆ GetInstance()

G4Pow * G4Pow::GetInstance ( void  )
static

Definition at line 55 of file G4Pow.cc.

56 {
57  if (fpInstance == 0)
58  {
59  static G4Pow geant4pow;
60  fpInstance = &geant4pow;
61  }
62  return fpInstance;
63 }
Definition: G4Pow.hh:56
static G4Pow * fpInstance
Definition: G4Pow.hh:106

◆ log10A()

G4double G4Pow::log10A ( G4double  A) const
inline

Definition at line 230 of file G4Pow.hh.

231 {
232  return logX(A)/lz[10];
233 }
double A(double temperature)
G4DataVector lz
Definition: G4Pow.hh:118
G4double logX(G4double x) const
Definition: G4Pow.hh:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log10Z()

G4double G4Pow::log10Z ( G4int  Z) const
inline

Definition at line 225 of file G4Pow.hh.

226 {
227  return lz[Z]/lz[10];
228 }
Float_t Z
G4DataVector lz
Definition: G4Pow.hh:118

◆ logA()

G4double G4Pow::logA ( G4double  A) const
inline

Definition at line 194 of file G4Pow.hh.

195 {
196  return (1.0 <= A ? logBase(A) : -logBase(1./A));
197 }
G4double logBase(G4double x) const
Definition: G4Pow.hh:171
double A(double temperature)
Here is the call graph for this function:

◆ logBase()

G4double G4Pow::logBase ( G4double  x) const
inlineprivate

Definition at line 171 of file G4Pow.hh.

172 {
173  G4double res;
174  if(a <= maxA2)
175  {
176  G4int i = G4int(max2*(a - 1) + 0.5);
177  if(i > max2) { i = max2; }
178  G4double x = a/(G4double(i)/max2 + 1) - 1;
179  res = lz2[i] + x*(1.0 - (0.5 - onethird*x)*x);
180  }
181  else if(a <= maxA)
182  {
183  G4int i = G4int(a + 0.5);
184  G4double x = a/G4double(i) - 1;
185  res = lz[i] + x*(1.0 - (0.5 - onethird*x)*x);
186  }
187  else
188  {
189  res = G4Log(a);
190  }
191  return res;
192 }
const G4double onethird
Definition: G4Pow.hh:108
int G4int
Definition: G4Types.hh:78
G4double maxA2
Definition: G4Pow.hh:112
const G4int max2
Definition: G4Pow.hh:109
G4double maxA
Definition: G4Pow.hh:111
G4double G4Log(G4double x)
Definition: G4Log.hh:230
double G4double
Definition: G4Types.hh:76
G4DataVector lz2
Definition: G4Pow.hh:119
G4DataVector lz
Definition: G4Pow.hh:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logfactorial()

G4double G4Pow::logfactorial ( G4int  Z) const
inline

Definition at line 269 of file G4Pow.hh.

270 {
271  return logfact[Z];
272 }
Float_t Z
G4DataVector logfact
Definition: G4Pow.hh:122
Here is the caller graph for this function:

◆ logX()

G4double G4Pow::logX ( G4double  x) const
inline

Definition at line 199 of file G4Pow.hh.

200 {
201  G4double res = 0.0;
202  G4double a = (1.0 <= x) ? x : 1.0/x;
203 
204  if(a <= maxA)
205  {
206  res = logBase(a);
207  }
208  else if(a <= ener[2])
209  {
210  res = logen[1] + logBase(a/ener[1]);
211  }
212  else if(a <= ener[3])
213  {
214  res = logen[2] + logBase(a/ener[2]);
215  }
216  else
217  {
218  res = G4Log(a);
219  }
220 
221  if(1.0 > x) { res = -res; }
222  return res;
223 }
G4double logBase(G4double x) const
Definition: G4Pow.hh:171
G4double maxA
Definition: G4Pow.hh:111
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4DataVector ener
Definition: G4Pow.hh:115
double G4double
Definition: G4Types.hh:76
G4DataVector logen
Definition: G4Pow.hh:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logZ()

G4double G4Pow::logZ ( G4int  Z) const
inline

Definition at line 166 of file G4Pow.hh.

167 {
168  return lz[Z];
169 }
Float_t Z
G4DataVector lz
Definition: G4Pow.hh:118
Here is the caller graph for this function:

◆ powA()

G4double G4Pow::powA ( G4double  A,
G4double  y 
) const
inline

Definition at line 259 of file G4Pow.hh.

260 {
261  return (0.0 == A ? 0.0 : expA(y*logX(A)));
262 }
Double_t y
double A(double temperature)
G4double expA(G4double A) const
Definition: G4Pow.hh:235
G4double logX(G4double x) const
Definition: G4Pow.hh:199
Here is the call graph for this function:

◆ powN()

G4double G4Pow::powN ( G4double  x,
G4int  n 
) const

Definition at line 128 of file G4Pow.cc.

129 {
130  if(0.0 == x) { return 0.0; }
131  if(std::abs(n) > 8) { return std::pow(x, G4double(n)); }
132  G4double res = 1.0;
133  if(n >= 0) { for(G4int i=0; i<n; ++i) { res *= x; } }
134  else if(n < 0)
135  {
136  G4double y = 1.0/x;
137  G4int nn = -n;
138  for(G4int i=0; i<nn; ++i) { res *= y; }
139  }
140  return res;
141 }
int G4int
Definition: G4Types.hh:78
Double_t y
Char_t n[5]
double G4double
Definition: G4Types.hh:76
Here is the caller graph for this function:

◆ powZ()

G4double G4Pow::powZ ( G4int  Z,
G4double  y 
) const
inline

Definition at line 254 of file G4Pow.hh.

255 {
256  return expA(y*lz[Z]);
257 }
Double_t y
Float_t Z
G4double expA(G4double A) const
Definition: G4Pow.hh:235
G4DataVector lz
Definition: G4Pow.hh:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Z13()

G4double G4Pow::Z13 ( G4int  Z) const
inline

Definition at line 127 of file G4Pow.hh.

128 {
129  return pz13[Z];
130 }
G4DataVector pz13
Definition: G4Pow.hh:117
Float_t Z
Here is the caller graph for this function:

◆ Z23()

G4double G4Pow::Z23 ( G4int  Z) const
inline

Definition at line 154 of file G4Pow.hh.

155 {
156  G4double x = Z13(Z);
157  return x*x;
158 }
Float_t Z
G4double Z13(G4int Z) const
Definition: G4Pow.hh:127
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ener

G4DataVector G4Pow::ener
private

Definition at line 115 of file G4Pow.hh.

◆ fact

G4DataVector G4Pow::fact
private

Definition at line 121 of file G4Pow.hh.

◆ fexp

G4DataVector G4Pow::fexp
private

Definition at line 120 of file G4Pow.hh.

◆ fpInstance

G4Pow * G4Pow::fpInstance = 0
staticprivate

Definition at line 106 of file G4Pow.hh.

◆ logen

G4DataVector G4Pow::logen
private

Definition at line 116 of file G4Pow.hh.

◆ logfact

G4DataVector G4Pow::logfact
private

Definition at line 122 of file G4Pow.hh.

◆ lz

G4DataVector G4Pow::lz
private

Definition at line 118 of file G4Pow.hh.

◆ lz2

G4DataVector G4Pow::lz2
private

Definition at line 119 of file G4Pow.hh.

◆ max2

const G4int G4Pow::max2
private

Definition at line 109 of file G4Pow.hh.

◆ maxA

G4double G4Pow::maxA
private

Definition at line 111 of file G4Pow.hh.

◆ maxA2

G4double G4Pow::maxA2
private

Definition at line 112 of file G4Pow.hh.

◆ maxAexp

G4double G4Pow::maxAexp
private

Definition at line 113 of file G4Pow.hh.

◆ onethird

const G4double G4Pow::onethird
private

Definition at line 108 of file G4Pow.hh.

◆ pz13

G4DataVector G4Pow::pz13
private

Definition at line 117 of file G4Pow.hh.


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