46 ed <<
"G4Physics2DVector is too short: nx= " << nx <<
" numy= " << ny;
47 G4Exception(
"G4Physics2DVector::G4Physics2DVector()",
"glob03",
65 numberOfXNodes = right.numberOfXNodes;
66 numberOfYNodes = right.numberOfYNodes;
68 verboseLevel = right.verboseLevel;
69 useBicubic = right.useBicubic;
71 xVector = right.xVector;
72 yVector = right.yVector;
90 numberOfXNodes = right.numberOfXNodes;
91 numberOfYNodes = right.numberOfYNodes;
93 verboseLevel = right.verboseLevel;
94 useBicubic = right.useBicubic;
106 xVector.resize(numberOfXNodes, 0.);
107 yVector.resize(numberOfYNodes, 0.);
108 value.resize(numberOfYNodes);
109 for(std::size_t j = 0; j < numberOfYNodes; ++j)
119 for(std::size_t j = 0; j < numberOfYNodes; ++j)
129 for(std::size_t i = 0; i < numberOfXNodes; ++i)
131 xVector[i] = right.xVector[i];
133 for(std::size_t j = 0; j < numberOfYNodes; ++j)
135 yVector[j] = right.yVector[j];
137 for(std::size_t i = 0; i < numberOfXNodes; ++i)
147 std::size_t& idy)
const
151 std::min(std::max(xx, xVector[0]), xVector[numberOfXNodes - 1]);
153 std::min(std::max(yy, yVector[0]), yVector[numberOfYNodes - 1]);
167 const G4double x2 = xVector[idx + 1];
169 const G4double y2 = yVector[idy + 1];
174 return ((y2 - y) * (v11 * (x2 - x) + v12 * (x - x1)) +
175 ((y - y1) * (v21 * (x2 - x) + v22 * (x - x1)))) /
176 ((x2 - x1) * (y2 - y1));
184 const std::size_t idx,
185 const std::size_t idy)
const
193 const G4double x2 = xVector[idx + 1];
195 const G4double y2 = yVector[idy + 1];
216 const G4double f1x = DerivativeX(idx, idy, dx);
217 const G4double f2x = DerivativeX(idx + 1, idy, dx);
218 const G4double f3x = DerivativeX(idx + 1, idy + 1, dx);
219 const G4double f4x = DerivativeX(idx, idy + 1, dx);
221 const G4double f1y = DerivativeY(idx, idy, dy);
222 const G4double f2y = DerivativeY(idx + 1, idy, dy);
223 const G4double f3y = DerivativeY(idx + 1, idy + 1, dy);
224 const G4double f4y = DerivativeY(idx, idy + 1, dy);
227 const G4double f1xy = DerivativeXY(idx, idy, dxy);
228 const G4double f2xy = DerivativeXY(idx + 1, idy, dxy);
229 const G4double f3xy = DerivativeXY(idx + 1, idy + 1, dxy);
230 const G4double f4xy = DerivativeXY(idx, idy + 1, dxy);
232 return f1 + f1y * h2 + (3 * (f4 - f1) - 2 * f1y - f4y) * h22 +
233 (2 * (f1 - f4) + f1y + f4y) * h23 + f1x * h1 + f1xy * h1 * h2 +
234 (3 * (f4x - f1x) - 2 * f1xy - f4xy) * h1 * h22 +
235 (2 * (f1x - f4x) + f1xy + f4xy) * h1 * h23 +
236 (3 * (f2 - f1) - 2 * f1x - f2x) * h12 +
237 (3 * f2y - 3 * f1y - 2 * f1xy - f2xy) * h12 * h2 +
238 (9 * (f1 - f2 + f3 - f4) + 6 * f1x + 3 * f2x - 3 * f3x - 6 * f4x +
239 6 * f1y - 6 * f2y - 3 * f3y + 3 * f4y + 4 * f1xy + 2 * f2xy + f3xy +
242 (6 * (-f1 + f2 - f3 + f4) - 4 * f1x - 2 * f2x + 2 * f3x + 4 * f4x -
243 3 * f1y + 3 * f2y + 3 * f3y - 3 * f4y - 2 * f1xy - f2xy - f3xy -
246 (2 * (f1 - f2) + f1x + f2x) * h13 +
247 (2 * (f1y - f2y) + f1xy + f2xy) * h13 * h2 +
248 (6 * (-f1 + f2 - f3 + f4) + 3 * (-f1x - f2x + f3x + f4x) - 4 * f1y +
249 4 * f2y + 2 * f3y - 2 * f4y - 2 * f1xy - 2 * f2xy - f3xy - f4xy) *
251 (4 * (f1 - f2 + f3 - f4) + 2 * (f1x + f2x - f3x - f4x) +
252 2 * (f1y - f2y - f3y + f4y) + f1xy + f2xy + f3xy + f4xy) *
259 const std::vector<G4double>& vecY)
262 std::size_t nx = vecX.size();
263 std::size_t ny = vecY.size();
267 ed <<
"G4Physics2DVector is too short: nx= " << nx <<
" ny= " << ny;
269 "Both lengths should be above 1");
275 for(std::size_t i = 0; i < nx; ++i)
277 xVector[i] = vecX[i];
279 for(std::size_t j = 0; j < ny; ++j)
281 yVector[j] = vecY[j];
290 G4int prec = out.precision();
291 out <<
G4int(type) <<
" " << numberOfXNodes <<
" " << numberOfYNodes
293 out << std::setprecision(8);
296 for(std::size_t i = 0; i < numberOfXNodes - 1; ++i)
298 out << xVector[i] <<
" ";
300 out << xVector[numberOfXNodes - 1] <<
G4endl;
301 for(std::size_t j = 0; j < numberOfYNodes - 1; ++j)
303 out << yVector[j] <<
" ";
305 out << yVector[numberOfYNodes - 1] <<
G4endl;
306 for(std::size_t j = 0; j < numberOfYNodes; ++j)
308 for(std::size_t i = 0; i < numberOfXNodes - 1; ++i)
328 if(in.fail() || 2 > nx || 2 > ny || nx >=
INT_MAX || ny >=
INT_MAX)
339 for(
G4int i = 0; i < nx; ++i)
347 for(
G4int j = 0; j < ny; ++j)
355 for(
G4int j = 0; j < ny; ++j)
357 for(
G4int i = 0; i < nx; ++i)
376 for(std::size_t j = 0; j < numberOfYNodes; ++j)
378 for(std::size_t i = 0; i < numberOfXNodes; ++i)
389 std::size_t& idy)
const
391 G4double y = std::min(std::max(yy, yVector[0]), yVector[numberOfYNodes - 1]);
396 G4double x1 = InterpolateLinearX(*(value[idy]), rand);
397 G4double x2 = InterpolateLinearX(*(value[idy + 1]), rand);
399 G4double del = yVector[idy + 1] - yVector[idy];
402 res += (x2 - x1) * (y - yVector[idy]) / del;
412 std::size_t nn = v.size();
418 std::size_t n2 =
nn / 2;
419 std::size_t n3 =
nn - 1;
431 n2 = (n3 + n1 + 1) / 2;
437 res += (y - v[n1]) * (xVector[n3] - res) / del;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4double > G4PV2DDataVector
G4bool Retrieve(std::ifstream &fIn)
G4Physics2DVector & operator=(const G4Physics2DVector &)
std::size_t FindBinLocationX(const G4double x, const std::size_t lastidx) const
void Store(std::ofstream &fOut) const
std::size_t FindBinLocationY(const G4double y, const std::size_t lastidy) const
void CopyData(const G4Physics2DVector &vec)
void PutVectors(const std::vector< G4double > &vecX, const std::vector< G4double > &vecY)
G4double BicubicInterpolation(const G4double x, const G4double y, const std::size_t idx, const std::size_t idy) const
G4double Value(G4double x, G4double y, std::size_t &lastidx, std::size_t &lastidy) const
void ScaleVector(G4double factor)
void PutValue(std::size_t idx, std::size_t idy, G4double value)
G4double GetValue(std::size_t idx, std::size_t idy) const
G4double FindLinearX(G4double rand, G4double y, std::size_t &lastidy) const