Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Allocator.hh,v 1.19 2009/10/29 16:01:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Allocator.hh,v 1.21 2010/04/01 12:43:12 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// ------------------------------------------------------------
@@ -65,12 +65,17 @@ class G4Allocator
// new and delete operators in the client <Type> object
inline void ResetStorage();
// Returns allocated storage to the free store, resets
// allocator and page sizes.
// Returns allocated storage to the free store, resets allocator.
// Note: contents in memory are lost using this call !
inline size_t GetAllocatedSize() const;
// Returns the size of the total memory allocated
inline int GetNoPages() const;
// Returns the total number of allocated pages
inline size_t GetPageSize() const;
// Returns the current size of a page
inline void IncreasePageSize( unsigned int sz );
// Resets allocator and increases default page size of a given factor
public: // without description
@@ -136,8 +141,6 @@ class G4Allocator
struct rebind { typedef G4Allocator<U> other; };
// Rebind allocator to type U
private:
G4AllocatorPool mem;
// Pool of elements of sizeof(Type)
};
@@ -213,6 +216,37 @@ size_t G4Allocator<Type>::GetAllocatedSize() const
return mem.Size();
}
// ************************************************************
// GetNoPages
// ************************************************************
//
template <class Type>
int G4Allocator<Type>::GetNoPages() const
{
return mem.GetNoPages();
}
// ************************************************************
// GetPageSize
// ************************************************************
//
template <class Type>
size_t G4Allocator<Type>::GetPageSize() const
{
return mem.GetPageSize();
}
// ************************************************************
// IncreasePageSize
// ************************************************************
//
template <class Type>
void G4Allocator<Type>::IncreasePageSize( unsigned int sz )
{
ResetStorage();
mem.GrowPageSize(sz);
}
// ************************************************************
// operator==
// ************************************************************
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4AllocatorPool.hh,v 1.5 2006/06/29 19:01:18 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4AllocatorPool.hh,v 1.7 2010/07/14 10:45:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// -------------------------------------------------------------------
@@ -57,9 +57,6 @@ class G4AllocatorPool
~G4AllocatorPool();
// Destructor. Return storage to the free store
G4AllocatorPool(const G4AllocatorPool& right);
// Copy constructor
inline void* Alloc();
// Allocate one element
inline void Free( void* b );
@@ -70,8 +67,17 @@ class G4AllocatorPool
void Reset();
// Return storage to the free store
inline int GetNoPages() const;
// Return the total number of allocated pages
inline unsigned int GetPageSize() const;
// Accessor for default page size
inline void GrowPageSize( unsigned int factor );
// Increase default page size by a given factor
private:
G4AllocatorPool(const G4AllocatorPool& right);
// Provate copy constructor
G4AllocatorPool& operator= (const G4AllocatorPool& right);
// Private equality operator
@@ -96,7 +102,7 @@ class G4AllocatorPool
private:
const unsigned int esize;
const unsigned int csize;
unsigned int csize;
G4PoolChunk* chunks;
G4PoolLink* head;
int nchunks;
@@ -141,4 +147,34 @@ G4AllocatorPool::Size() const
return nchunks*csize;
}
// ************************************************************
// GetNoPages
// ************************************************************
//
inline int
G4AllocatorPool::GetNoPages() const
{
return nchunks;
}
// ************************************************************
// GetPageSize
// ************************************************************
//
inline unsigned int
G4AllocatorPool::GetPageSize() const
{
return csize;
}
// ************************************************************
// GrowPageSize
// ************************************************************
//
inline void
G4AllocatorPool::GrowPageSize( unsigned int sz )
{
csize = (sz) ? sz*csize : csize;
}
#endif
@@ -24,16 +24,16 @@
// ********************************************************************
//
//
// $Id: G4FPEDetection.hh,v 1.2 2006/11/15 16:00:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4FPEDetection.hh,v 1.5 2010/10/14 17:02:52 mkelsey Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// -*- C++ -*-
//
// -----------------------------------------------------------------------
// This global method should be used on LINUX platforms with gcc compiler
// for activating NaN detection and FPE signals, and forcing abortion of
// the application at the time these are detected.
// This global method should be used on LINUX or MacOSX platforms with gcc
// compiler for activating NaN detection and FPE signals, and forcing
// abortion of the application at the time these are detected.
// Meant to be used for debug purposes, can be activated by compiling the
// "run" module with the flag G4FPE_DEBUG set in the environment.
// -----------------------------------------------------------------------
@@ -41,22 +41,27 @@
#ifndef G4FPEDetection_h
#define G4FPEDetection_h 1
#include <iostream>
#include <stdlib.h> /* abort(), exit() */
#ifdef __linux__
#ifdef __GNUC__
#include <features.h>
#include <fenv.h>
#include <csignal>
#include <iostream>
struct sigaction termaction, oldaction;
void TerminationSignalHandler(int sig)
static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
{
std::cerr << "ERROR: " << sig;
std::string message;
switch (SIGFPE)
{
std::string message = "Floating-point exception (FPE).";
if (sinfo) {
switch (sinfo->si_code) {
#ifdef FPE_NOOP /* BUG: MacOSX uses this instead of INTDIV */
case FPE_NOOP:
#endif
case FPE_INTDIV:
message = "Integer divide by zero.";
break;
@@ -84,13 +89,15 @@
default:
message = "Unknown error.";
break;
}
}
std::cerr << " - " << message << std::endl;
std::cerr << " - " << message << std::endl;
::abort();
}
void InvalidOperationDetection()
static void InvalidOperationDetection()
{
std::cout << std::endl
<< " "
@@ -105,17 +112,160 @@
//(void) feenableexcept( FE_OVERFLOW );
//(void) feenableexcept( FE_UNDERFLOW );
sigset_t *def_set;
def_set=&termaction.sa_mask;
sigfillset(def_set);
sigdelset(def_set,SIGFPE);
termaction.sa_handler=TerminationSignalHandler;
termaction.sa_flags=0;
sigaction(SIGFPE, &termaction,&oldaction);
sigdelset(&termaction.sa_mask,SIGFPE);
termaction.sa_sigaction=TerminationSignalHandler;
termaction.sa_flags=SA_SIGINFO;
sigaction(SIGFPE, &termaction, &oldaction);
}
#endif
#else
void InvalidOperationDetection() {;}
#elif __MACH__ /* MacOSX */
#include <fenv.h>
#include <signal.h>
#define DEFINED_PPC (defined(__ppc__) || defined(__ppc64__))
#define DEFINED_INTEL (defined(__i386__) || defined(__x86_64__))
#if DEFINED_PPC
#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 & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
fenv = (fenv & ~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 & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
fenv &= still_on;
return ( fesetenv (&fenv) ? -1 : old_excepts );
}
#elif DEFINED_INTEL
static inline int feenableexcept (unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
old_excepts; // previous masks
if ( fegetenv (&fenv) ) { return -1; }
old_excepts = fenv.__control & FE_ALL_EXCEPT;
// unmask
//
fenv.__control &= ~new_excepts;
fenv.__mxcsr &= ~(new_excepts << 7);
return ( fesetenv (&fenv) ? -1 : old_excepts );
}
static inline int fedisableexcept (unsigned int excepts)
{
static fenv_t fenv;
unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
old_excepts; // all previous masks
if ( fegetenv (&fenv) ) { return -1; }
old_excepts = fenv.__control & FE_ALL_EXCEPT;
// mask
//
fenv.__control |= new_excepts;
fenv.__mxcsr |= new_excepts << 7;
return ( fesetenv (&fenv) ? -1 : old_excepts );
}
#endif /* PPC or INTEL enabling */
static void TerminationSignalHandler(int sig, siginfo_t* sinfo, void* /* context */)
{
std::cerr << "ERROR: " << sig;
std::string message = "Floating-point exception (FPE).";
if (sinfo) {
switch (sinfo->si_code) {
#ifdef FPE_NOOP /* BUG: MacOSX uses this instead of INTDIV */
case FPE_NOOP:
#endif
case FPE_INTDIV:
message = "Integer divide by zero.";
break;
case FPE_INTOVF:
message = "Integer overflow.";
break;
case FPE_FLTDIV:
message = "Floating point divide by zero.";
break;
case FPE_FLTOVF:
message = "Floating point overflow.";
break;
case FPE_FLTUND:
message = "Floating point underflow.";
break;
case FPE_FLTRES:
message = "Floating point inexact result.";
break;
case FPE_FLTINV:
message = "Floating point invalid operation.";
break;
case FPE_FLTSUB:
message = "Subscript out of range.";
break;
default:
message = "Unknown error.";
break;
}
}
std::cerr << " - " << message << std::endl;
::abort();
}
static void InvalidOperationDetection()
{
struct sigaction termaction, oldaction;
std::cout << std::endl
<< " "
<< "############################################" << std::endl
<< " "
<< "!!! WARNING - FPE detection is activated !!!" << std::endl
<< " "
<< "############################################" << std::endl;
feenableexcept ( FE_DIVBYZERO );
feenableexcept ( FE_INVALID );
// fedisableexcept( FE_OVERFLOW );
// fedisableexcept( FE_UNDERFLOW );
sigdelset(&termaction.sa_mask,SIGFPE);
termaction.sa_sigaction=TerminationSignalHandler;
termaction.sa_flags=SA_SIGINFO;
sigaction(SIGFPE, &termaction, &oldaction);
}
#else /* Not Linux, nor MacOSX ... */
static void InvalidOperationDetection() {;}
#endif
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.hh,v 1.11 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4LPhysicsFreeVector.hh,v 1.14 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
// ------------------------------------------------------------------
@@ -73,10 +73,6 @@ public: // with description
G4int GetVerboseLevel(G4int);
G4double GetLastEnergy();
size_t GetLastBin();
void DumpValues();
private:
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.icc,v 1.14 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4LPhysicsFreeVector.icc,v 1.17 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
// ------------------------------------------------------------------
@@ -67,17 +67,6 @@ G4int G4LPhysicsFreeVector::GetVerboseLevel(G4int)
return verboseLevel;
}
inline
G4double G4LPhysicsFreeVector::GetLastEnergy()
{
return lastEnergy;
}
inline
size_t G4LPhysicsFreeVector::GetLastBin()
{
return lastBin;
}
inline
size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsFreeVector.hh,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PhysicsFreeVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
//--------------------------------------------------------------------
@@ -75,7 +75,7 @@ class G4PhysicsFreeVector : public G4PhysicsVector
// 'binVector'. 'binVector' and 'dataVector' need to have
// the same vector length.
~G4PhysicsFreeVector();
virtual ~G4PhysicsFreeVector();
// Destructor
void PutValue( size_t binNumber, G4double binValue,
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLinearVector.hh,v 1.11 2008/09/22 11:37:09 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLinearVector.hh,v 1.13 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
//--------------------------------------------------------------------
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLnVector.hh,v 1.13 2008/09/22 11:37:09 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLnVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
//--------------------------------------------------------------------
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLogVector.hh,v 1.13 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLogVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
//--------------------------------------------------------------------
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.hh,v 1.12 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PhysicsOrderedFreeVector.hh,v 1.14 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Definition
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.icc,v 1.9 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PhysicsOrderedFreeVector.icc,v 1.11 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Inline Functions Definitions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.hh,v 1.25 2009/11/04 11:32:43 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PhysicsVector.hh,v 1.31 2010/05/28 05:13:43 kurasige Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
//---------------------------------------------------------------
@@ -52,7 +52,9 @@
// 02 Apr. 2008, A.Bagulya : Added SplineInterpolation() and SetSpline()
// 11 May 2009, V.Ivanchenko : Added ComputeSecondDerivatives
// 19 Jun. 2009, V.Ivanchenko : Removed hidden bin
//
// 22 Dec. 2009 H.Kurashige : Use pointers to G4PVDataVector
// 04 May. 2010 H.Kurashige : Use G4PhysicsVectorCache
// 28 May 2010 H.Kurashige : Stop using pointers to G4PVDataVector
//---------------------------------------------------------------
#ifndef G4PhysicsVector_h
@@ -64,8 +66,11 @@
#include <iostream>
#include <fstream>
#include "G4PhysicsVectorCache.hh"
#include "G4PhysicsVectorType.hh"
typedef std::vector<G4double> G4PVDataVector;
class G4PhysicsVector
{
public:
@@ -85,7 +90,7 @@ class G4PhysicsVector
virtual ~G4PhysicsVector();
// destructor
inline G4double Value(G4double theEnergy);
G4double Value(G4double theEnergy);
// Get the cross-section/energy-loss value corresponding to the
// given energy. An appropriate interpolation is used to calculate
// the value.
@@ -174,6 +179,12 @@ class G4PhysicsVector
friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&);
G4double GetLastEnergy() const;
G4double GetLastValue() const;
size_t GetLastBin() const;
// Get cache values
protected:
virtual size_t FindBinLocation(G4double theEnergy) const=0;
@@ -185,8 +196,6 @@ class G4PhysicsVector
protected:
typedef std::vector<G4double> G4PVDataVector;
G4PhysicsVectorType type; // The type of PhysicsVector (enumerator)
G4double edgeMin; // Energy of first point
@@ -194,24 +203,22 @@ class G4PhysicsVector
size_t numberOfNodes;
G4double lastEnergy; // Cache the last input value
G4double lastValue; // Cache the last output value
size_t lastBin; // Cache the last bin location
G4PhysicsVectorCache* cache;
G4PVDataVector dataVector; // Vector to keep the crossection/energyloss
G4PVDataVector binVector; // Vector to keep energy
G4PVDataVector secDerivative; // Vector to keep second derivatives
G4PVDataVector dataVector; // Vector to keep the crossection/energyloss
G4PVDataVector binVector; // Vector to keep energy
G4PVDataVector secDerivative; // Vector to keep second derivatives
private:
G4bool SplinePossible();
inline G4double LinearInterpolation();
inline G4double LinearInterpolation(G4int lastBin);
// Linear interpolation function
inline G4double SplineInterpolation();
inline G4double SplineInterpolation(G4int lastBin);
// Spline interpolation function
inline void Interpolation();
inline void Interpolation(G4int lastBin);
G4String comment;
G4bool useSpline;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.icc,v 1.23 2009/11/18 11:42:03 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PhysicsVector.icc,v 1.30 2010/09/20 16:22:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
//---------------------------------------------------------------
@@ -42,10 +42,28 @@
//
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::GetLastEnergy() const
{
return cache->lastEnergy;
}
inline
G4double G4PhysicsVector::GetLastValue() const
{
return cache->lastValue;
}
inline
size_t G4PhysicsVector::GetLastBin() const
{
return cache->lastBin;
}
inline
G4double G4PhysicsVector::operator[](const size_t binNumber) const
{
return dataVector[binNumber];
return dataVector[binNumber];
}
//---------------------------------------------------------------
@@ -75,7 +93,15 @@ inline
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::LinearInterpolation()
G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&)
{
return Value(theEnergy);
}
//------------------------------------------------
inline
G4double G4PhysicsVector::LinearInterpolation(G4int lastBin)
{
// Linear interpolation is used to get the value. If the give energy
// is in the highest bin, no interpolation will be Done. Because
@@ -83,17 +109,17 @@ inline
// the following interpolation is valid even the current locBin=
// numberOfBin-1.
G4double intplFactor = (lastEnergy-binVector[lastBin])
/ (binVector[lastBin+1]-binVector[lastBin]); // Interpolation factor
G4double intplFactor = (cache->lastEnergy-binVector[lastBin])
/ (binVector[lastBin + 1]-binVector[lastBin]); // Interpol. factor
return dataVector[lastBin] +
( dataVector[lastBin+1]-dataVector[lastBin] ) * intplFactor;
( dataVector[lastBin + 1]-dataVector[lastBin] ) * intplFactor;
}
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::SplineInterpolation()
G4double G4PhysicsVector::SplineInterpolation(G4int lastBin)
{
// Spline interpolation is used to get the value. If the give energy
// is in the highest bin, no interpolation will be Done. Because
@@ -105,73 +131,30 @@ inline
// check bin value
G4double x1 = binVector[lastBin];
G4double x2 = binVector[lastBin+1];
G4double x2 = binVector[lastBin + 1];
G4double delta = x2 - x1;
G4double a = (x2 - lastEnergy)/delta;
G4double b = (lastEnergy - x1)/delta;
G4double a = (x2 - cache->lastEnergy)/delta;
G4double b = (cache->lastEnergy - x1)/delta;
// Final evaluation of cubic spline polynomial for return
G4double y1 = dataVector[lastBin];
G4double y2 = dataVector[lastBin+1];
G4double y2 = dataVector[lastBin + 1];
G4double res = a*y1 + b*y2 +
( (a*a*a - a)*secDerivative[lastBin] +
(b*b*b - b)*secDerivative[lastBin+1] )*delta*delta/6.0;
(b*b*b - b)*secDerivative[lastBin + 1] )*delta*delta/6.0;
return res;
}
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&)
{
return Value(theEnergy);
}
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::Value(G4double theEnergy)
{
// Use cache for speed up - check if the value 'theEnergy' is same as the
// last call. If it is same, then use the last bin location. Also the
// value 'theEnergy' lies between the last energy and low edge of of the
// bin of last call, then the last bin location is used.
if( theEnergy == lastEnergy ) {
} else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin]) {
lastEnergy = theEnergy;
Interpolation();
} else if( theEnergy <= edgeMin ) {
lastBin = 0;
lastEnergy = edgeMin;
lastValue = dataVector[0];
} else if( theEnergy >= edgeMax ){
lastBin = numberOfNodes-2;
lastEnergy = edgeMax;
lastValue = dataVector[numberOfNodes-1];
} else {
lastBin = FindBinLocation(theEnergy);
if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;}
lastEnergy = theEnergy;
Interpolation();
}
return lastValue;
}
//---------------------------------------------------------------
inline
void G4PhysicsVector::Interpolation()
void G4PhysicsVector::Interpolation(G4int lastBin)
{
if(useSpline) { lastValue = SplineInterpolation(); }
else { lastValue = LinearInterpolation(); }
if(useSpline) { cache->lastValue = SplineInterpolation(lastBin); }
else { cache->lastValue = LinearInterpolation(lastBin); }
}
//---------------------------------------------------------------
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * 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: G4PhysicsVectorCache.hh,v 1.3 2010/05/05 15:44:39 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
// ---------------------------------------------------------------
// GEANT 4 class header file
//
// G4PhysicsVectorCache
//
// Class description:
//
// This class includes cache data in use by G4PhysicsVector:
// last input value, last output value, last bin location.
// Author:
// 04.05.2010 Hisaya Kurashige
// ---------------------------------------------------------------
#ifndef G4PhysicsVectorCache_h
#define G4PhysicsVectorCache_h 1
#include "globals.hh"
#include "G4Allocator.hh"
class G4PhysicsVectorCache
{
public:
G4PhysicsVectorCache() : lastEnergy(-DBL_MAX), lastValue(0.), lastBin(0) {}
// Constructor
~G4PhysicsVectorCache() {}
// Destructor
G4double lastEnergy; // Cache the last input value
G4double lastValue; // Cache the last output value
size_t lastBin; // Cache the last bin location
};
#endif
+22 -9
View File
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Pow.hh,v 1.2 2009/07/03 11:35:07 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Pow.hh,v 1.7 2010/08/24 08:12:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// -------------------------------------------------------------------
@@ -34,7 +34,10 @@
// Class description:
//
// Utility singleton class for the fast computation of log and pow
// functions
// functions. Integer argument should in the interval 0-255, no
// check is performed inside these methods for performance reasons.
// Computations with double arguments are fast for the interval
// 0.5-255.5, standard library is used in the opposite case
// Author: Vladimir Ivanchenko
//
@@ -78,10 +81,12 @@ class G4Pow
//
inline G4double powZ(G4int Z, G4double y);
inline G4double powA(G4double A, G4double y);
G4double powN(G4double x, G4int n);
// Fast factorial
//
inline G4double factorial(G4int Z);
inline G4double logfactorial(G4int Z);
private:
@@ -97,6 +102,7 @@ class G4Pow
G4DataVector pz13;
G4DataVector lz;
G4DataVector fact;
G4DataVector logfact;
};
// -------------------------------------------------------------------
@@ -108,12 +114,13 @@ inline G4double G4Pow::Z13(G4int Z)
inline G4double G4Pow::A13(G4double A)
{
const G4int maxZ = 256;
const G4double minA = 0.5000001;
const G4double maxA = 255.5;
G4double res;
G4int i = G4int(A + 0.5);
if((i >= 1) && (i < maxZ))
if((A >= minA) && (A <= maxA))
{
G4int i = G4int(A + 0.5);
G4double x = (1.0 - A/G4double(i))*onethird;
res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
}
@@ -143,12 +150,13 @@ inline G4double G4Pow::logZ(G4int Z)
inline G4double G4Pow::logA(G4double A)
{
const G4int maxZ = 256;
const G4double minA = 0.5000001;
const G4double maxA = 255.5;
G4double res;
G4int i = G4int(A + 0.5);
if((i >= 1) && (i < maxZ))
if((A >= minA) && (A <= maxA))
{
G4int i = G4int(A + 0.5);
G4double x = 1.0 - A/G4double(i);
res = lz[i] + x*(1.0 - 0.5*x + onethird*x*x);
}
@@ -184,6 +192,11 @@ inline G4double G4Pow::factorial(G4int Z)
return fact[Z];
}
inline G4double G4Pow::logfactorial(G4int Z)
{
return logfact[Z];
}
// -------------------------------------------------------------------
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Version.hh,v 1.25 2009/11/24 13:51:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Version.hh,v 1.28 2010/11/24 10:57:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Version information
//
@@ -46,18 +46,18 @@
// |--> patch number
#ifndef G4VERSION_NUMBER
#define G4VERSION_NUMBER 930
#define G4VERSION_NUMBER 940
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-09-03 $"
#define G4VERSION_TAG "$Name: geant4-09-04 $"
#endif
// as variables
#include "G4String.hh"
static const G4String G4Version = "$Name: geant4-09-03 $";
static const G4String G4Date = "(18-December-2009)";
static const G4String G4Version = "$Name: geant4-09-04 $";
static const G4String G4Date = "(17-December-2010)";
#endif
+3 -3
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ios.hh,v 1.10 2006/06/29 19:03:43 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ios.hh,v 1.12 2010/10/27 07:40:06 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// ---------------------------------------------------------------
@@ -41,7 +41,7 @@
#include <iostream>
#if defined G4IOS_EXPORT
#if defined G4IOS_ALLOC_EXPORT
extern G4DLLEXPORT std::ostream G4cout;
extern G4DLLEXPORT std::ostream G4cerr;
#else
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4strstreambuf.hh,v 1.16 2007/11/13 17:35:06 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4strstreambuf.hh,v 1.18 2010/10/27 07:40:06 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
// ====================================================================
//
// G4strstreambuf
@@ -40,7 +40,7 @@
class G4strstreambuf;
#if defined G4IOS_EXPORT
#if defined G4IOS_ALLOC_EXPORT
extern G4DLLEXPORT G4strstreambuf G4coutbuf;
extern G4DLLEXPORT G4strstreambuf G4cerrbuf;
#else
+10 -2
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: templates.hh,v 1.13 2008/08/15 12:15:53 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: templates.hh,v 1.14 2010/07/16 15:48:51 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// -*- C++ -*-
@@ -108,6 +108,14 @@ typedef float Float;
#define MAXFLOAT std::numeric_limits<float>::max() // 3.40282347e+38F
#endif
#ifndef INT_MAX /* Max decimal value of a int */
#define INT_MAX std::numeric_limits<int>::max() // 2147483647
#endif
#ifndef INT_MIN /* Min decimal value of a int */
#define INT_MIN std::numeric_limits<int>::min() // -2147483648
#endif
//---------------------------------
template <class T>