Import Geant4 10.7.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2020-06-26 10:23:25 +02:00
parent c02c370437
commit 67ba86d073
1871 changed files with 174422 additions and 131884 deletions
@@ -23,104 +23,99 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4PhysicsOrderedFreeVector class implementation
//
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Implementation
////////////////////////////////////////////////////////////////////////
//
// File: G4PhysicsOrderedFreeVector.cc
// Version: 2.0
// Created: 1996-08-13
// Author: Juliet Armstrong
// Updated: 1997-03-25 by Peter Gumplinger
// > cosmetics (only)
// 1998-11-11 by Peter Gumplinger
// > initialize all data members of the base class in
// derived class constructors
// 2000-11-11 by H.Kurashige
// > use STL vector for dataVector and binVector
// 2009-06-19 by V.Ivanchenko
// > removed hidden bin
// 2013-10-02 by V.Ivanchenko removed FindBinLocation
//
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
// Author: Juliet Armstrong (TRIUMF), 13 August 1996
// Revisions:
// - 11.11.2000, H.Kurashige: use STL vector for dataVector and binVector
// - 19.06.2009, V.Ivanchenko: removed hidden bin
// --------------------------------------------------------------------
#include "G4PhysicsOrderedFreeVector.hh"
// --------------------------------------------------------------------
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
: G4PhysicsVector()
{
type = T_G4PhysicsOrderedFreeVector;
type = T_G4PhysicsOrderedFreeVector;
}
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
G4double *Values,
size_t VectorLength)
// --------------------------------------------------------------------
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double* Energies,
G4double* Values,
std::size_t VectorLength)
: G4PhysicsVector()
{
type = T_G4PhysicsOrderedFreeVector;
type = T_G4PhysicsOrderedFreeVector;
dataVector.reserve(VectorLength);
binVector.reserve(VectorLength);
dataVector.reserve(VectorLength);
binVector.reserve(VectorLength);
for (size_t i = 0 ; i < VectorLength ; ++i)
{
InsertValues(Energies[i], Values[i]);
}
for(std::size_t i = 0; i < VectorLength; ++i)
{
InsertValues(Energies[i], Values[i]);
}
}
G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector()
{}
// --------------------------------------------------------------------
G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector() {}
// --------------------------------------------------------------------
void G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
{
std::vector<G4double>::iterator binLoc =
std::lower_bound(binVector.begin(), binVector.end(), energy);
auto binLoc = std::lower_bound(binVector.cbegin(), binVector.cend(), energy);
size_t binIdx = binLoc - binVector.begin(); // Iterator difference!
std::size_t binIdx = binLoc - binVector.cbegin(); // Iterator difference!
std::vector<G4double>::iterator dataLoc = dataVector.begin() + binIdx;
auto dataLoc = dataVector.cbegin() + binIdx;
binVector.insert(binLoc, energy);
dataVector.insert(dataLoc, value);
binVector.insert(binLoc, energy);
dataVector.insert(dataLoc, value);
++numberOfNodes;
edgeMin = binVector.front();
edgeMax = binVector.back();
++numberOfNodes;
edgeMin = binVector.front();
edgeMax = binVector.back();
}
// --------------------------------------------------------------------
G4double G4PhysicsOrderedFreeVector::GetEnergy(G4double aValue)
{
G4double e;
if (aValue <= GetMinValue()) {
e = edgeMin;
} else if (aValue >= GetMaxValue()) {
e = edgeMax;
} else {
size_t closestBin = FindValueBinLocation(aValue);
e = LinearInterpolationOfEnergy(aValue, closestBin);
}
return e;
G4double e;
if(aValue <= GetMinValue())
{
e = edgeMin;
}
else if(aValue >= GetMaxValue())
{
e = edgeMax;
}
else
{
std::size_t closestBin = FindValueBinLocation(aValue);
e = LinearInterpolationOfEnergy(aValue, closestBin);
}
return e;
}
size_t G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
// --------------------------------------------------------------------
std::size_t G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
{
size_t bin = std::lower_bound(dataVector.begin(), dataVector.end(), aValue)
- dataVector.begin() - 1;
bin = std::min(bin, numberOfNodes-2);
return bin;
std::size_t bin =
std::lower_bound(dataVector.cbegin(), dataVector.cend(), aValue) -
dataVector.cbegin() - 1;
bin = std::min(bin, numberOfNodes - 2);
return bin;
}
G4double G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(G4double aValue,
size_t bin)
// --------------------------------------------------------------------
G4double G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(
G4double aValue, std::size_t bin)
{
G4double res = binVector[bin];
G4double del = dataVector[bin+1] - dataVector[bin];
if(del > 0.0) {
res += (aValue - dataVector[bin])*(binVector[bin+1] - res)/del;
}
return res;
G4double res = binVector[bin];
G4double del = dataVector[bin + 1] - dataVector[bin];
if(del > 0.0)
{
res += (aValue - dataVector[bin]) * (binVector[bin + 1] - res) / del;
}
return res;
}