Files
geant4/source/global/management/include/G4Physics2DVector.icc
T
2016-06-10 11:51:14 +02:00

176 lines
4.9 KiB
Plaintext

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
//
//---------------------------------------------------------------
// GEANT 4 class inline source file
//
// G4Physics2DVector.icc
//---------------------------------------------------------------
inline
G4double G4Physics2DVector::Value(G4double x, G4double y) const
{
size_t idx = 0;
size_t idy = 0;
return Value(x, y, idx, idy);
}
inline void G4Physics2DVector::PutX(size_t idx, G4double val)
{
xVector[idx] = val;
}
inline void G4Physics2DVector::PutY(size_t idy, G4double val)
{
yVector[idy] = val;
}
inline void
G4Physics2DVector::PutValue(size_t idx, size_t idy, G4double val)
{
(*(value[idy]))[idx] = val;
}
inline G4double G4Physics2DVector::GetX(size_t index) const
{
return xVector[index];
}
inline G4double G4Physics2DVector::GetY(size_t index) const
{
return yVector[index];
}
inline
G4double G4Physics2DVector::GetValue(size_t idx, size_t idy) const
{
return (*(value[idy]))[idx];
}
inline
G4double G4Physics2DVector::FindLinearX(G4double rand, G4double y) const
{
size_t idy = 0;
return FindLinearX(rand, y, idy);
}
inline size_t G4Physics2DVector::GetLengthX() const
{
return numberOfXNodes;
}
inline size_t G4Physics2DVector::GetLengthY() const
{
return numberOfYNodes;
}
inline G4PhysicsVectorType G4Physics2DVector::GetType() const
{
return type;
}
inline void G4Physics2DVector::SetBicubicInterpolation(G4bool val)
{
useBicubic = val;
}
inline size_t G4Physics2DVector::FindBin(G4double z,
const G4PV2DDataVector& v,
size_t idx,
size_t idxmax) const
{
size_t id = idx;
if(z < v[1]) {
id = 0;
} else if(z >= v[idxmax-2]) {
id = idxmax - 2;
} else if(z < v[idx] || z >= v[idx+1]) {
id = FindBinLocation(z, v);
}
return id;
}
inline size_t
G4Physics2DVector::FindBinLocationX(G4double x, size_t lastidx) const
{
return FindBin(x, xVector, lastidx, numberOfXNodes);
}
inline size_t
G4Physics2DVector::FindBinLocationY(G4double y, size_t lastidy) const
{
return FindBin(y, yVector, lastidy, numberOfYNodes);
}
inline void G4Physics2DVector::SetVerboseLevel(G4int val)
{
verboseLevel = val;
}
inline G4int G4Physics2DVector::GetVerboseLevel() const
{
return verboseLevel;
}
inline G4double
G4Physics2DVector::DerivativeX(size_t idx, size_t idy, G4double fac) const
{
size_t i1 = idx;
if(i1 > 0) { --i1; }
size_t i2 = idx;
if(i2+1 < numberOfXNodes) { ++i2; }
return fac*(GetValue(i2, idy) - GetValue(i1, idy))/(GetX(i2) - GetX(i1));
}
inline G4double
G4Physics2DVector::DerivativeY(size_t idx, size_t idy, G4double fac) const
{
size_t i1 = idy;
if(i1 > 0) { --i1; }
size_t i2 = idy;
if(i2+1 < numberOfYNodes) { ++i2; }
return fac*(GetValue(idx, i2) - GetValue(idx, i1))/(GetY(i2) - GetY(i1));
}
inline G4double
G4Physics2DVector::DerivativeXY(size_t idx, size_t idy, G4double fac) const
{
size_t i1 = idx;
if(i1 > 0) { --i1; }
size_t i2 = idx;
if(i2+1 < numberOfXNodes) { ++i2; }
size_t j1 = idy;
if(j1 > 0) { --j1; }
size_t j2 = idy;
if(j2+1 < numberOfYNodes) { ++j2; }
return fac*(GetValue(i2, j2) - GetValue(i1, j2) - GetValue(i2, j1)
+ GetValue(i1, j1))/((GetX(i2) - GetX(i1))*(GetY(j2) - GetY(j1)));
}