Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -77,6 +77,15 @@ inline
inline
void G4PhysicsTable::insertAt (size_t idx, G4PhysicsVector* pvec)
{
if(idx > entries())
{
G4ExceptionDescription ed;
ed << "Sprcified index (" << idx << ") is larger than the size of the vector ("
<< entries() << ").";
G4Exception("G4PhysicsTable::insertAt()","Global_PhysTbl0001",
FatalException,ed);
}
G4PhysicsTableIterator itr=begin();
for (size_t i=0; i<idx; ++i) { itr++; }
G4PhysCollection::insert(itr, pvec);
@@ -58,6 +58,7 @@
// instead of G4Pow G4Log is used
// 15 Mar. 2019 M.Novak : added Value method with the known log-energy value
// that can avoid the log call in case of log-vectors
// 16 July 2019 M.Novak : special LogVectorValue method for log-vectors
//---------------------------------------------------------------
#ifndef G4PhysicsVector_h
@@ -93,11 +94,11 @@ class G4PhysicsVector
// the value. Consumer code got changed index and may reuse it
// for the next call to save CPU for bin location.
G4double Value(G4double theEnergy, G4double theLogEnergy,
size_t& lastidx) const;
// Same as Value() above, with the additional log-kinetic energy input
// argument that can be used for faster index computation in case of
// log-vectors.
inline G4double LogVectorValue(const G4double theEnergy,
const G4double theLogEnergy) const;
// Same as the Value method above but specialised for log-vector type.
// Note, unlike the general Value method above, this method will work
// properly only in case of G4PhysicsLogVector-s.
inline G4double Value(G4double theEnergy) const;
// Get the cross-section/energy-loss value corresponding to the
@@ -106,11 +107,6 @@ class G4PhysicsVector
// it should be used instead of the previous method if bin location
// cannot be kept thread safe
inline G4double Value(G4double theEnergy, G4double theLogEnergy) const;
// Same as Value() above with the additional log-kinetic energy input
// argument that can be used for faster index computation in case of
// log-vectors.
inline G4double GetValue(G4double theEnergy, G4bool& isOutRange) const;
// Obsolete method to get value, isOutRange is not used anymore.
// This method is kept for the compatibility reason.
@@ -163,9 +159,9 @@ class G4PhysicsVector
// min value 0, max value VectorLength-1
// idx is suggested bin number from user code
inline size_t FindBin(G4double energy, G4double logener, size_t idx) const;
// Same as FindBin() above with the additional logenergy input argument
// that can be used for faster index computation in case of log-vectors.
inline size_t ComputeLogVectorBin(const G4double logenergy) const;
// Computes the lower index the energy bin in case of log-vector i.e.
// in case of vectors with equal bin widths on log-scale.
void FillSecondDerivatives();
// Initialise second derivatives for spline keeping
@@ -246,17 +242,11 @@ class G4PhysicsVector
// find low edge index of a bin for given energy
// min value 0, max value VectorLength-1
inline size_t FindBinLocation(G4double theEnergy,
G4double theLogEnergy) const;
// same as FindBinLocation() above with the additional log-energy input
// argument that can be used for faster index computations in case of
// log-vectors.
G4bool useSpline;
protected:
G4double dBin; // Bin width - useful only for fixed binning
G4double invdBin; // 1/Bin width - useful only for fixed binning
G4double baseBin; // Set this in constructor for performance
G4int verboseLevel;
@@ -194,11 +194,11 @@ size_t G4PhysicsVector::FindBinLocation(G4double theEnergy) const
{
size_t bin;
if(type == T_G4PhysicsLogVector) {
bin = size_t(G4Log(theEnergy)/dBin - baseBin);
bin = size_t(G4Log(theEnergy)*invdBin - baseBin);
if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(theEnergy > binVector[bin+1]) { ++bin; }
} else if(type == T_G4PhysicsLinearVector) {
bin = size_t( theEnergy/dBin - baseBin );
bin = size_t( theEnergy*invdBin - baseBin );
if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(theEnergy > binVector[bin+1]) { ++bin; }
} else {
@@ -210,26 +210,6 @@ size_t G4PhysicsVector::FindBinLocation(G4double theEnergy) const
}
//---------------------------------------------------------------
inline
size_t G4PhysicsVector::FindBinLocation(G4double theEnergy,
G4double theLogEnergy) const
{
size_t bin;
const G4double ex = (type==T_G4PhysicsLogVector) ? theLogEnergy : theEnergy;
if(type == T_G4PhysicsLogVector || type == T_G4PhysicsLinearVector) {
bin = size_t(ex/dBin - baseBin);
if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(theEnergy > binVector[bin+1]) { ++bin; }
} else {
// Bin location proposed by K.Genser (FNAL)
bin = std::lower_bound(binVector.begin(), binVector.end(), theEnergy)
- binVector.begin() - 1;
}
return std::min(bin, numberOfNodes-2);
}
//---------------------------------------------------------------
inline size_t G4PhysicsVector::FindBin(G4double e, size_t idx) const
@@ -246,23 +226,16 @@ inline size_t G4PhysicsVector::FindBin(G4double e, size_t idx) const
return id;
}
//---------------------------------------------------------------
inline
size_t G4PhysicsVector::FindBin(G4double e, G4double loge, size_t idx) const
size_t G4PhysicsVector::ComputeLogVectorBin(const G4double loge) const
{
size_t id = idx;
if(e < binVector[1]) {
id = 0;
} else if(e >= binVector[numberOfNodes-2]) {
id = numberOfNodes - 2;
} else if(idx >= numberOfNodes || e < binVector[idx]
|| e > binVector[idx+1]) {
id = FindBinLocation(e, loge);
}
return id;
return size_t(std::max(0., std::min(loge*invdBin-baseBin, numberOfNodes-2.)));
}
//---------------------------------------------------------------
inline
@@ -272,13 +245,6 @@ inline
return Value(theEnergy, idx);
}
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::Value(G4double theEnergy, G4double theLogEnergy) const
{
size_t idx=0;
return Value(theEnergy, theLogEnergy, idx);
}
//---------------------------------------------------------------
@@ -290,3 +256,34 @@ inline
}
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::LogVectorValue(const G4double theEnergy,
const G4double theLogEnergy) const
{
// handle cases below/above the enrgy grid (by ek, idx that gives b=0/1)
// ek = x[0] if e<=x[0] and idx will be 0 ^ b=0 => so y=y0
// ek = x[N-1] if e>=x[N-1] and idx will be N-2 ^ b=1 => so y=y_{N-1}
const G4double ek = std::max(binVector[0],
std::min(binVector[numberOfNodes-1], theEnergy));
// compute the lowerindex of the bin (idx \in [0,N-2] will be guaranted)
const size_t idx = ComputeLogVectorBin(theLogEnergy);
// perform the interpolation
const G4double x1 = binVector[idx];
const G4double x2 = binVector[idx+1];
const G4double dl = x2-x1;
// note: all corner cases of the previous methods are covered and eventually
// gives b=0/1 that results in y=y0\y_{N-1} if e<=x[0]/e>=x[N-1] or
// y=y_i/y_{i+1} if e<x[i]/e>=x[i+1] due to small numerical errors
const G4double b = std::max(0., std::min(1., (ek - x1)/dl));
if (useSpline) { // spline interpolation
const G4double os = 0.166666666667; // 1./6.
const G4double a = 1.0 - b;
const G4double c0 = (a*a*a-a)*secDerivative[idx];
const G4double c1 = (b*b*b-b)*secDerivative[idx+1];
return a*dataVector[idx] + b*dataVector[idx+1] + (c0+c1)*dl*dl*os;
} else { // linear interpolation
const G4double y1 = dataVector[idx];
const G4double y2 = dataVector[idx+1];
return y1 + b*(y2-y1);
}
}
+2 -2
View File
@@ -108,8 +108,8 @@ public:
inline G4String& remove(str_size);
inline G4String& remove(str_size, str_size);
inline G4int first(char) const;
inline G4int last(char) const;
inline std::size_t first(char) const;
inline std::size_t last(char) const;
inline G4bool contains(const std::string&) const;
inline G4bool contains(char) const;
@@ -219,12 +219,12 @@ inline G4String& G4String::remove(str_size pos, str_size N)
return *this;
}
inline G4int G4String::first(char ch) const
inline std::size_t G4String::first(char ch) const
{
return find(ch);
}
inline G4int G4String::last(char ch) const
inline std::size_t G4String::last(char ch) const
{
return rfind(ch);
}
@@ -247,7 +247,7 @@ inline G4String G4String::strip (G4int strip_Type, char ch)
switch ( strip_Type ) {
case leading:
{
for(i=0;i<length();i++)
for(i=0;i<length();++i)
{ if (std_string::operator[](i) != ch) { break; } }
retVal = substr(i,length()-i);
}
@@ -255,18 +255,18 @@ inline G4String G4String::strip (G4int strip_Type, char ch)
case trailing:
{
G4int j=0;
for(j=length()-1;j>=0;j--)
for(j=G4int(length()-1);j>=0;--j)
{ if (std_string::operator[](j) != ch) { break; } }
retVal = substr(0,j+1);
}
break;
case both:
{
for(i=0;i<length();i++)
for(i=0;i<length();++i)
{ if (std_string::operator[](i) != ch) { break; } }
G4String tmp(substr(i,length()-i));
G4int k=0;
for(k=tmp.length()-1;k>=0;k--)
for(k=G4int(tmp.length()-1);k>=0;--k)
{ if (tmp.std_string::operator[](k) != ch) { break; } }
retVal = tmp.substr(0,k+1);
}
+105 -27
View File
@@ -37,7 +37,7 @@
// Fundamental definitions
#ifndef G4GMAKE
#include "G4GlobalConfig.hh"
# include "G4GlobalConfig.hh"
#endif
#include "globals.hh"
@@ -45,41 +45,119 @@
//----------------------------------------------------------------------------//
#ifdef GEANT4_USE_TIMEMORY
# if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wexceptions"
# pragma GCC diagnostic ignored "-Wunused-private-field"
# endif
# include <timemory/timemory.hpp>
#include <timemory/timemory.hpp>
typedef tim::auto_timer G4AutoTimer;
inline void InitializeTiMemory()
{
tim::manager* instance = tim::manager::instance();
instance->enable(true);
}
# if defined __GNUC__
# pragma GCC diagnostic pop
# endif
using G4AutoTimer = tim::auto_timer;
#else
#define TIMEMORY_AUTO_TIMER(str)
#define TIMEMORY_AUTO_TIMER_OBJ(str) {}
# include <ostream>
# include <string>
#define TIMEMORY_BASIC_AUTO_TIMER(str)
#define TIMEMORY_BASIC_AUTO_TIMER_OBJ(str) {}
namespace tim
{
template <typename... _Args>
void timemory_init(_Args...)
{
}
inline void timemory_finalize() {}
inline void print_env() {}
#define TIMEMORY_DEBUG_BASIC_AUTO_TIMER(str)
#define TIMEMORY_DEBUG_AUTO_TIMER(str)
/// this provides "functionality" for *_HANDLE macros
/// and can be omitted if these macros are not utilized
struct dummy
{
template <typename... _Args>
dummy(_Args&&...)
{
}
~dummy() = default;
dummy(const dummy&) = default;
dummy(dummy&&) = default;
dummy& operator=(const dummy&) = default;
dummy& operator=(dummy&&) = default;
inline void InitializeTiMemory()
{ }
void start() {}
void stop() {}
void conditional_start() {}
void conditional_stop() {}
void report_at_exit(bool) {}
template <typename... _Args>
void mark_begin(_Args&&...)
{
}
template <typename... _Args>
void mark_end(_Args&&...)
{
}
friend std::ostream& operator<<(std::ostream& os, const dummy&) { return os; }
};
} // namespace tim
// startup/shutdown/configure
# define TIMEMORY_INIT(...)
# define TIMEMORY_FINALIZE()
# define TIMEMORY_CONFIGURE(...)
// label creation
# define TIMEMORY_BASIC_LABEL(...) std::string("")
# define TIMEMORY_LABEL(...) std::string("")
# define TIMEMORY_JOIN(...) std::string("")
// define an object
# define TIMEMORY_BLANK_MARKER(...)
# define TIMEMORY_BASIC_MARKER(...)
# define TIMEMORY_MARKER(...)
// define an unique pointer object
# define TIMEMORY_BLANK_POINTER(...)
# define TIMEMORY_BASIC_POINTER(...)
# define TIMEMORY_POINTER(...)
// define an object with a caliper reference
# define TIMEMORY_BLANK_CALIPER(...)
# define TIMEMORY_BASIC_CALIPER(...)
# define TIMEMORY_CALIPER(...)
// define a static object with a caliper reference
# define TIMEMORY_STATIC_BLANK_CALIPER(...)
# define TIMEMORY_STATIC_BASIC_CALIPER(...)
# define TIMEMORY_STATIC_CALIPER(...)
// invoke member function on caliper reference or type within reference
# define TIMEMORY_CALIPER_APPLY(...)
# define TIMEMORY_CALIPER_TYPE_APPLY(...)
// get an object
# define TIMEMORY_BLANK_HANDLE(...) tim::dummy()
# define TIMEMORY_BASIC_HANDLE(...) tim::dummy()
# define TIMEMORY_HANDLE(...) tim::dummy()
// get a pointer to an object
# define TIMEMORY_BLANK_POINTER_HANDLE(...) nullptr
# define TIMEMORY_BASIC_POINTER_HANDLE(...) nullptr
# define TIMEMORY_POINTER_HANDLE(...) nullptr
// debug only
# define TIMEMORY_DEBUG_BLANK_MARKER(...)
# define TIMEMORY_DEBUG_BASIC_MARKER(...)
# define TIMEMORY_DEBUG_MARKER(...)
// auto-timers
# define TIMEMORY_BLANK_AUTO_TIMER(...)
# define TIMEMORY_BASIC_AUTO_TIMER(...)
# define TIMEMORY_AUTO_TIMER(...)
# define TIMEMORY_BLANK_AUTO_TIMER_HANDLE(...)
# define TIMEMORY_BASIC_AUTO_TIMER_HANDLE(...)
# define TIMEMORY_AUTO_TIMER_HANDLE(...)
# define TIMEMORY_DEBUG_BASIC_AUTO_TIMER(...)
# define TIMEMORY_DEBUG_AUTO_TIMER(...)
using G4AutoTimer = tim::dummy;
#endif
//----------------------------------------------------------------------------//
#endif
@@ -23,14 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// Version information
//
// History:
// 26.09.05 K.Murakami - Created
//
// --------------------------------------------------------------------
#ifndef G4VERSION_HH
#define G4VERSION_HH
@@ -48,7 +44,7 @@
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-10-06-beta-01 $"
#define G4VERSION_TAG "$Name: geant4-10-06 $"
#endif
// as variables
@@ -57,10 +53,10 @@
#include "G4String.hh"
#ifdef G4MULTITHREADED
static const G4String G4Version = "$Name: geant4-10-06-beta-01 [MT]$";
static const G4String G4Version = "$Name: geant4-10-06 [MT]$";
#else
static const G4String G4Version = "$Name: geant4-10-06-beta-01 $";
static const G4String G4Version = "$Name: geant4-10-06 $";
#endif
static const G4String G4Date = "(28-June-2019)";
static const G4String G4Date = "(6-December-2019)";
#endif
@@ -203,8 +203,8 @@ inline int G4rint(double ad)
// G4ConsumeParameters(val);
// }
//
template <typename _Tp, typename... _Args>
inline void G4ConsumeParameters(_Tp, _Args...)
template <typename... _Args>
inline void G4ConsumeParameters(_Args&&...)
{ }
#endif // templates_h