Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -50,8 +50,14 @@
//
// JustWarning
// Just display messages.
//
// IgnoreTheIssue
// No message generated.
//
// Author: M.Asai, 19 August 2002
// 05 September 2023 : IgnoreTheIssue added
//
// --------------------------------------------------------------------
#ifndef G4ExceptionSeverity_hh
#define G4ExceptionSeverity_hh 1
@@ -62,6 +68,7 @@ enum G4ExceptionSeverity
FatalErrorInArgument,
RunMustBeAborted,
EventMustBeAborted,
JustWarning
JustWarning,
IgnoreTheIssue
};
#endif
@@ -256,7 +256,44 @@ static inline int fedisableexcept(unsigned int excepts)
return (fesetenv(&fenv) ? -1 : old_excepts);
}
# endif /* PPC or INTEL enabling */
# elif(defined(__arm) || defined(__arm64) || defined(__aarch64__)) // Apple Silicon
# define FE_EXCEPT_SHIFT 22 // shift flags right to get masks
# define FM_ALL_EXCEPT FE_ALL_EXCEPT >> FE_EXCEPT_SHIFT
static inline int feenableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = (excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT,
old_excepts; // all previous masks
if(fegetenv(&fenv))
{
return -1;
}
old_excepts = (fenv.__fpcr & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
fenv.__fpcr = (fenv.__fpcr & ~new_excepts) | new_excepts;
return (fesetenv(&fenv) ? -1 : old_excepts);
}
static inline int fedisableexcept(unsigned int excepts)
{
static fenv_t fenv;
unsigned int still_on = ~((excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT),
old_excepts; // previous masks
if(fegetenv(&fenv))
{
return -1;
}
old_excepts = (fenv.__fpcr & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
fenv.__fpcr = fenv.__fpcr | still_on;
return (fesetenv(&fenv) ? -1 : old_excepts);
}
# endif /* PPC or INTEL or Apple Silicon enabling */
static void TerminationSignalHandler(int sig, siginfo_t* sinfo,
void* /* context */)
@@ -86,6 +86,8 @@ public:
// If energy coincide with previously added energy then
// this new pair is added after
void InsertValues(const G4double energy, const G4double value);
void EnableLogBinSearch(const G4int n = 1);
// Obsolete method
inline void PutValue(const std::size_t index,
@@ -92,6 +92,11 @@ public:
inline G4double LogVectorValue(const G4double energy,
const G4double theLogEnergy) const;
// Same as the Value() method above but specialised for free vector
// with logarithmic seach of bin number
inline G4double LogFreeVectorValue(const G4double energy,
const G4double theLogEnergy) const;
// Returns the value for the specified index of the dataVector
// The boundary check will not be done
inline G4double operator[](const std::size_t index) const;
@@ -194,6 +199,8 @@ private:
const G4double energy) const;
// Assuming (edgeMin <= energy <= edgeMax).
inline std::size_t LogBin(const G4double energy, const G4double loge) const;
inline std::size_t BinaryBin(const G4double energy) const;
inline std::size_t GetBin(const G4double energy) const;
protected:
@@ -204,9 +211,14 @@ protected:
G4double invdBin = 0.0; // 1/Bin width for linear and log vectors
G4double logemin = 0.0; // used only for log vector
G4double iBin1 = 0.0; // 1/Bin width for scale log vector
G4double lmin1 = 0.0; // used for log search of free vector
G4int verboseLevel = 0;
std::size_t idxmax = 0;
std::size_t imax1 = 0;
std::size_t numberOfNodes = 0;
std::size_t nLogNodes = 0;
G4PhysicsVectorType type = T_G4PhysicsFreeVector;
// The type of PhysicsVector (enumerator)
@@ -214,6 +226,7 @@ protected:
std::vector<G4double> binVector; // energy
std::vector<G4double> dataVector; // crossection/energyloss
std::vector<G4double> secDerivative; // second derivatives
std::vector<std::size_t> scale; // log seach
private:
@@ -139,7 +139,7 @@ inline G4double G4PhysicsVector::Interpolation(const std::size_t idx,
G4double res = y1 + b * dy;
if(useSpline) // spline interpolation
if (useSpline) // spline interpolation
{
const G4double c0 = (2.0 - b) * secDerivative[idx];
const G4double c1 = (1.0 + b) * secDerivative[idx + 1];
@@ -153,8 +153,30 @@ inline G4double G4PhysicsVector::Interpolation(const std::size_t idx,
inline std::size_t G4PhysicsVector::ComputeLogVectorBin(
const G4double loge) const
{
return std::min( static_cast<G4int>((loge - logemin) * invdBin),
static_cast<G4int>(idxmax) );
return static_cast<std::size_t>( std::min( static_cast<G4int>((loge - logemin) * invdBin),
static_cast<G4int>(idxmax) ) );
}
// ---------------------------------------------------------------
inline std::size_t
G4PhysicsVector::LogBin(const G4double e, const G4double loge) const
{
std::size_t idx =
scale[std::min( static_cast<G4int>((loge - lmin1) * iBin1),
static_cast<G4int>(imax1) )];
for (; idx <= idxmax; ++idx)
{
if (e >= binVector[idx] && e <= binVector[idx + 1]) { break; }
}
return idx;
}
// ---------------------------------------------------------------
inline std::size_t G4PhysicsVector::BinaryBin(const G4double e) const
{
// Bin location proposed by K.Genser (FNAL)
return std::lower_bound(binVector.cbegin(), binVector.cend(), e) -
binVector.cbegin() - 1;
}
// ---------------------------------------------------------------
@@ -168,14 +190,12 @@ inline std::size_t G4PhysicsVector::GetBin(const G4double e) const
break;
case T_G4PhysicsLinearVector:
bin = std::min( static_cast<G4int>((e - edgeMin) * invdBin),
static_cast<G4int>(idxmax) );
bin = static_cast<std::size_t>( std::min( static_cast<G4int>((e - edgeMin) * invdBin),
static_cast<G4int>(idxmax) ) );
break;
default:
// Bin location proposed by K.Genser (FNAL)
bin = std::lower_bound(binVector.cbegin(), binVector.cend(), e) -
binVector.cbegin() - 1;
bin = (nLogNodes > 0) ? LogBin(e, G4Log(e)) : BinaryBin(e);
}
return bin;
}
@@ -185,12 +205,12 @@ inline G4double
G4PhysicsVector::Value(const G4double e, std::size_t& idx) const
{
G4double res;
if(idx + 1 < numberOfNodes &&
e >= binVector[idx] && e <= binVector[idx+1])
if (idx + 1 < numberOfNodes &&
e >= binVector[idx] && e <= binVector[idx+1])
{
res = Interpolation(idx, e);
}
else if(e > edgeMin && e < edgeMax)
else if (e > edgeMin && e < edgeMax)
{
idx = GetBin(e);
res = Interpolation(idx, e);
@@ -202,7 +222,7 @@ G4PhysicsVector::Value(const G4double e, std::size_t& idx) const
}
else
{
res = dataVector[numberOfNodes - 1];
res = dataVector[idxmax + 1];
idx = idxmax;
}
return res;
@@ -212,7 +232,7 @@ G4PhysicsVector::Value(const G4double e, std::size_t& idx) const
inline G4double G4PhysicsVector::Value(G4double e) const
{
G4double res;
if(e > edgeMin && e < edgeMax)
if (e > edgeMin && e < edgeMax)
{
const std::size_t idx = GetBin(e);
res = Interpolation(idx, e);
@@ -223,7 +243,7 @@ inline G4double G4PhysicsVector::Value(G4double e) const
}
else
{
res = dataVector[numberOfNodes - 1];
res = dataVector[idxmax + 1];
}
return res;
}
@@ -239,18 +259,39 @@ inline G4double
G4PhysicsVector::LogVectorValue(const G4double e, const G4double loge) const
{
G4double res;
if(e > edgeMin && e < edgeMax)
if (e > edgeMin && e < edgeMax)
{
const std::size_t idx = ComputeLogVectorBin(loge);
res = Interpolation(idx, e);
}
else if(e <= edgeMin)
else if (e <= edgeMin)
{
res = dataVector[0];
}
else
{
res = dataVector[numberOfNodes - 1];
res = dataVector[idxmax - 1];
}
return res;
}
// ---------------------------------------------------------------
inline G4double
G4PhysicsVector::LogFreeVectorValue(const G4double e, const G4double loge) const
{
G4double res;
if (e > edgeMin && e < edgeMax)
{
const std::size_t idx = LogBin(e, loge);
res = Interpolation(idx, e);
}
else if (e <= edgeMin)
{
res = dataVector[0];
}
else
{
res = dataVector[idxmax + 1];
}
return res;
}
@@ -121,18 +121,10 @@ using thread_unlock =
// mutex for specific to type T:
// G4AutoLock l(G4TypeMutex<G4Cache<T>>());
template <typename _Tp>
G4Mutex& G4TypeMutex(const unsigned int& _n = 0)
G4Mutex& G4TypeMutex()
{
static G4Mutex* _mutex = new G4Mutex();
if(_n == 0)
return *_mutex;
static std::vector<G4Mutex*> _mutexes;
if(_n > _mutexes.size())
_mutexes.resize(_n, nullptr);
if(!_mutexes[_n])
_mutexes[_n] = new G4Mutex();
return *(_mutexes[_n - 1]);
static G4Mutex _mutex;
return _mutex;
}
// Helper function for getting a unique static recursive_mutex for a
@@ -143,18 +135,10 @@ G4Mutex& G4TypeMutex(const unsigned int& _n = 0)
// G4RecursiveAutoLock
// l(G4TypeRecursiveMutex<G4Cache<T>>());
template <typename _Tp>
G4RecursiveMutex& G4TypeRecursiveMutex(const unsigned int& _n = 0)
G4RecursiveMutex& G4TypeRecursiveMutex()
{
static auto* _mutex = new G4RecursiveMutex();
if(_n == 0)
return *(_mutex);
static std::vector<G4RecursiveMutex*> _mutexes;
if(_n > _mutexes.size())
_mutexes.resize(_n, nullptr);
if(!_mutexes[_n])
_mutexes[_n] = new G4RecursiveMutex();
return *(_mutexes[_n - 1]);
static G4RecursiveMutex _mutex;
return _mutex;
}
#if defined(G4MULTITHREADED)
@@ -55,11 +55,11 @@
/// (taking December as 0, the start of new development of the next major/minor release).
///
#ifndef G4VERSION_REFERENCE_TAG
#define G4VERSION_REFERENCE_TAG -1
#define G4VERSION_REFERENCE_TAG 00
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-11-02-beta-01 $"
#define G4VERSION_TAG "$Name: geant4-11-02 $"
#endif
// as variables
@@ -68,10 +68,10 @@
#include "G4Types.hh"
#ifdef G4MULTITHREADED
static const G4String G4Version = "$Name: geant4-11-02-beta-01 [MT]$";
static const G4String G4Version = "$Name: geant4-11-02 [MT]$";
#else
static const G4String G4Version = "$Name: geant4-11-02-beta-01 $";
static const G4String G4Version = "$Name: geant4-11-02 $";
#endif
static const G4String G4Date = "(30-June-2023)";
static const G4String G4Date = "(8-December-2023)";
#endif