// // ******************************************************************** // * 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. * // ******************************************************************** // // G4Physics2DVector inline implementation // // Author: Vladimir Ivanchenko, 25.09.2011 // -------------------------------------------------------------------- inline G4double G4Physics2DVector::Value(G4double x, G4double y) const { std::size_t idx = 0; std::size_t idy = 0; return Value(x, y, idx, idy); } inline void G4Physics2DVector::PutX(std::size_t idx, G4double val) { xVector[idx] = val; } inline void G4Physics2DVector::PutY(std::size_t idy, G4double val) { yVector[idy] = val; } inline void G4Physics2DVector::PutValue(std::size_t idx, std::size_t idy, G4double val) { (*(value[idy]))[idx] = val; } inline G4double G4Physics2DVector::GetX(std::size_t index) const { return xVector[index]; } inline G4double G4Physics2DVector::GetY(std::size_t index) const { return yVector[index]; } inline G4double G4Physics2DVector::GetValue(std::size_t idx, std::size_t idy) const { return (*(value[idy]))[idx]; } inline G4double G4Physics2DVector::FindLinearX(G4double rand, G4double y) const { std::size_t idy = 0; return FindLinearX(rand, y, idy); } inline std::size_t G4Physics2DVector::GetLengthX() const { return numberOfXNodes; } inline std::size_t G4Physics2DVector::GetLengthY() const { return numberOfYNodes; } inline G4PhysicsVectorType G4Physics2DVector::GetType() const { return type; } inline void G4Physics2DVector::SetBicubicInterpolation(G4bool val) { useBicubic = val; } inline std::size_t G4Physics2DVector::FindBin(const G4double z, const G4PV2DDataVector& v, const std::size_t idx, const std::size_t idxmax) const { std::size_t id = idx; if(z <= v[1]) { id = 0; } else if(z >= v[idxmax]) { id = idxmax; } else if(idx > idxmax || z < v[idx] || z > v[idx + 1]) { id = std::lower_bound(v.begin(), v.end(), z) - v.begin() - 1; } return id; } inline std::size_t G4Physics2DVector::FindBinLocationX( const G4double x, const std::size_t idx) const { return FindBin(x, xVector, idx, numberOfXNodes - 2); } inline std::size_t G4Physics2DVector::FindBinLocationY( const G4double y, const std::size_t idy) const { return FindBin(y, yVector, idy, numberOfYNodes - 2); } inline void G4Physics2DVector::SetVerboseLevel(G4int val) { verboseLevel = val; } inline G4double G4Physics2DVector::DerivativeX(std::size_t idx, std::size_t idy, G4double fac) const { std::size_t i1 = idx; if(i1 > 0) { --i1; } std::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(std::size_t idx, std::size_t idy, G4double fac) const { std::size_t i1 = idy; if(i1 > 0) { --i1; } std::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(std::size_t idx, std::size_t idy, G4double fac) const { std::size_t i1 = idx; if(i1 > 0) { --i1; } std::size_t i2 = idx; if(i2 + 1 < numberOfXNodes) { ++i2; } std::size_t j1 = idy; if(j1 > 0) { --j1; } std::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))); }