Import Geant4 9.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:15:05 +02:00
parent b79225fb37
commit 74cad5e589
3877 changed files with 234205 additions and 167127 deletions
+60 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.216 2008/12/08 14:17:15 gcosmo Exp $
$Id: History,v 1.234 2009/12/07 09:24:27 vnivanch Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,65 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Dec 7, 2009 V.Ivanchenko (global-V09-02-12)
- G4PhysicsVector: (L.Pandola) fixed initialisation of lastEnergy to -DBL_MAX
allowing to have negative scale of energy
Nov 24, 2009 G.Cosmo (global-V09-02-11)
- Changed date for release 9.3.
Nov 17, 2009 V.Ivanchenko (global-V09-02-10)
- G4PhysicsVector: fixed Value() method for the case when energy is
around 'edgeMax'; adding extra protection.
Nov 04, 2009 V.Ivanchenko (global-V09-02-09)
- G4PhysicsVector: cleaned up initialisation of cached values;
simplified Value() method, now not looking into previous bin;
added method ScaleVector() needed for ICRU'73 data.
Oct 29, 2009 G.Cosmo (global-V09-02-08)
- Cleared warning for unused argument in G4Allocator internal method.
Aug 07, 2009 G.Cosmo (global-V09-02-07)
- Some improvements to G4String and G4SubString implementation of operators
and comparison stub functions, to reduce generation of temporaries.
- Removed obsolete static hash(s) method.
Jul 03, 2009 V.Ivanchenko (global-V09-02-06)
- New class G4Pow, a singleton for fast computation of log() and pow() for
integer and double arguments in the interval [1-256].
- G4PhysicsVector:
o Added ComputeSecDerivative() and SplinePossible() methods as a
computation of Spline coefficients for small number of bins.
o Removed old obsolete hidden bin approach.
o Use std::vector for second derivatives instead of C arrays.
May 26, 2009 A.Bagulya (global-V09-02-05)
- G4PhysicsVector: do not change flag "useSpline" during initialisation
to address bug in N02 reported by valgrind
May 26, 2009 A.Bagulya (global-V09-02-04)
- G4PhysicsVector: set limits of number of bins for spline: 4 for the case
of first derivatives defined; 5 for the case when "Not-a-Knot" algorithm
is used.
May 15, 2009 P.Arce (global-V09-02-03)
- Added G4ErrorStage enum to G4ErrorPropagatorData class.
May 13, 2009 A.Bagulya (global-V09-02-02)
- G4PhysicsVector: added method ComputeSecondDerivatives() for the case when
user provides first derivative at endpoits; use "Not-a-Knot" algorithm for
the computation of second derivatives in default method
FillSecondDerivatives().
- Changed date for release 9.3-beta.
Mar 16, 2009 G.Cosmo (global-V09-02-01)
- Changed date for release 9.2.p01.
Jan 27, 2009 G.Cosmo (global-V09-02-00)
- Correction in management/GNUmakefile to CPPFLAGS, adding G4RF_DEBUG in
case enabled.
Dec 08, 2008 G.Cosmo (global-V09-01-18)
- Added new constructor G4String(const char*, str_size).
+4 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.5 2004/06/11 14:18:58 gcosmo Exp $
# $Id: GNUmakefile,v 1.6 2009/01/27 08:45:28 gcosmo Exp $
# --------------------------------------------------------------
# GNUmakefile for global management. Gabriele Cosmo, 26/9/96.
# --------------------------------------------------------------
@@ -12,5 +12,8 @@ endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -DG4IOS_EXPORT
ifdef G4RF_DEBUG
CPPFLAGS += -DG4RF_DEBUG
endif
include $(G4INSTALL)/config/common.gmk
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Allocator.hh,v 1.18 2006/06/29 19:01:16 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Allocator.hh,v 1.19 2009/10/29 16:01:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// ------------------------------------------------------------
@@ -98,7 +98,7 @@ class G4Allocator
const_pointer address(const_reference r) const { return &r; }
// Returns the address of values
pointer allocate(size_type n, void* hint = 0)
pointer allocate(size_type n, void* = 0)
{
// Allocates space for n elements of type Type, but does not initialise
//
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ErrorPropagatorData.hh,v 1.3 2007/06/08 10:33:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ErrorPropagatorData.hh,v 1.5 2009/05/19 13:31:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------------
@@ -37,7 +37,6 @@
// Utility class to provide access to mode, state, target
// and manager verbosity for the error propagation classes.
// History:
// - Created. P.Arce, 2004.
// --------------------------------------------------------------------
@@ -55,6 +54,10 @@ enum G4ErrorState { G4ErrorState_PreInit = 1,
G4ErrorState_Propagating,
G4ErrorState_TargetCloserThanBoundary,
G4ErrorState_StoppedAtTarget };
enum G4ErrorStage { G4ErrorStage_Inflation = 1,
G4ErrorStage_Deflation };
class G4ErrorTarget;
class G4ErrorPropagatorData
@@ -72,6 +75,9 @@ public: // with description
G4ErrorState GetState() const;
void SetState( G4ErrorState sta );
G4ErrorStage GetStage() const;
void SetStage( G4ErrorStage sta );
const G4ErrorTarget* GetTarget( G4bool mustExist = 0) const;
void SetTarget( const G4ErrorTarget* target );
@@ -93,6 +99,8 @@ private:
G4ErrorState theState;
G4ErrorStage theStage;
G4ErrorTarget* theTarget;
static G4int theVerbosity;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ErrorPropagatorData.icc,v 1.4 2007/06/08 10:33:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ErrorPropagatorData.icc,v 1.5 2009/05/14 13:46:40 arce Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// Class G4ErrorPropagatorData inline implementation
@@ -57,6 +57,18 @@ G4ErrorState G4ErrorPropagatorData::GetState() const
return theState;
}
inline
void G4ErrorPropagatorData::SetStage( G4ErrorStage sta )
{
theStage = sta;
}
inline
G4ErrorStage G4ErrorPropagatorData::GetStage() const
{
return theStage;
}
inline
const G4ErrorTarget* G4ErrorPropagatorData::GetTarget( G4bool mustExist ) const
{
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.icc,v 1.13 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4LPhysicsFreeVector.icc,v 1.14 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// ------------------------------------------------------------------
@@ -51,7 +51,7 @@ void G4LPhysicsFreeVector::PutValues(size_t binNumber,
dataVector[binNumber] = dataValue;
if(binNumber == 0)
{ edgeMin = binValue; }
else if( numberOfBin - 1 == binNumber)
else if( numberOfNodes - 1 == binNumber)
{ edgeMax = binValue; }
}
@@ -83,8 +83,8 @@ inline
size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
G4int n2 = numberOfNodes/2;
G4int n3 = numberOfNodes - 1;
while (n1 != n3 - 1)
{
if (theEnergy > binVector[n2])
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsFreeVector.hh,v 1.12 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsFreeVector.hh,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//--------------------------------------------------------------------
@@ -107,7 +107,7 @@ size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const
// be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
size_t lowerBound = 0;
size_t upperBound = numberOfBin-1;
size_t upperBound = numberOfNodes-2;
while (lowerBound <= upperBound)
{
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.hh,v 1.11 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsOrderedFreeVector.hh,v 1.12 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Definition
@@ -85,7 +85,7 @@ class G4PhysicsOrderedFreeVector : public G4PhysicsVector
// Methods
////////////
void InsertValues(G4double energy, G4double value);
void InsertValues(G4double energy, G4double value);
G4double GetLowEdgeEnergy(size_t binNumber) const;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.icc,v 1.8 2006/06/29 19:02:31 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsOrderedFreeVector.icc,v 1.9 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Inline Functions Definitions
@@ -72,7 +72,7 @@ G4double G4PhysicsOrderedFreeVector::GetMinLowEdgeEnergy()
inline
void G4PhysicsOrderedFreeVector::DumpValues()
{
for (size_t i = 0; i < numberOfBin; i++)
for (size_t i = 0; i < numberOfNodes; i++)
{
G4cout << binVector[i] << "\t" << dataVector[i] << G4endl;
}
@@ -82,8 +82,8 @@ inline
size_t G4PhysicsOrderedFreeVector::FindBinLocation(G4double theEnergy) const
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
G4int n2 = numberOfNodes/2;
G4int n3 = numberOfNodes - 1;
while (n1 != n3 - 1)
{
if (theEnergy > binVector[n2])
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.hh,v 1.18 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsVector.hh,v 1.25 2009/11/04 11:32:43 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//---------------------------------------------------------------
@@ -50,6 +50,8 @@
// 11 Nov. 2000, H.Kurashige : Use STL vector for dataVector and binVector
// 09 Mar. 2001, H.Kurashige : Added G4PhysicsVectorType & Store/Retrieve()
// 02 Apr. 2008, A.Bagulya : Added SplineInterpolation() and SetSpline()
// 11 May 2009, V.Ivanchenko : Added ComputeSecondDerivatives
// 19 Jun. 2009, V.Ivanchenko : Removed hidden bin
//
//---------------------------------------------------------------
@@ -83,46 +85,80 @@ class G4PhysicsVector
virtual ~G4PhysicsVector();
// destructor
inline G4double GetValue(G4double theEnergy, G4bool& isOutRange);
inline 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.
// [Note] isOutRange is not used anymore. This argument is kept
// for the compatibility reason.
inline G4double GetValue(G4double theEnergy, G4bool& isOutRange);
// Obolete method to get value, isOutRange is not used anymore.
// This method is kept for the compatibility reason.
G4int operator==(const G4PhysicsVector &right) const ;
G4int operator!=(const G4PhysicsVector &right) const ;
inline G4double operator[](const size_t binNumber) const ;
// Returns simply the value in the bin specified by 'binNumber'
// of the dataVector. The boundary check will be Done. If you
// don't want this check, use the operator ().
// of the dataVector. The boundary check will not be done.
inline G4double operator()(const size_t binNumber) const ;
// Returns simply the value in the bin specified by 'binNumber'
// of the dataVector. The boundary check will not be Done. If
// you want this check, use the operator [].
// of the dataVector. The boundary check will not be Done.
inline void PutValue(size_t binNumber, G4double theValue);
inline void PutValue(size_t index, G4double theValue);
// Put 'theValue' into the bin specified by 'binNumber'.
// Take note that the 'binNumber' starts from '0'.
// To fill the vector, you have beforehand to Construct a vector
// Take note that the 'index' starts from '0'.
// To fill the vector, you have beforehand to construct a vector
// by the constructor with Emin, Emax, Nbin. 'theValue' should
// be the crosssection/energyloss value corresponding to the low
// edge energy of the bin specified by 'binNumber'. You can get
// the low edge energy value of a bin by GetLowEdgeEnergy().
// be the crosssection/energyloss value corresponding to the
// energy of the index. You can get this energy by the next method
// or by the old method GetLowEdgeEnergy().
void ScaleVector(G4double factorE, G4double factorV);
// Scale all values of the vector and second derivatives
// by factorV, energies by vectorE. This method may be applied
// for example after Retrieve a vector from an external file to
// convert values into Geant4 units
inline G4double Energy(size_t index) const;
// Returns simply the value in the energy specified by 'index'
// of the energy vector. The boundary check will not be done.
// Use this function when you fill physis vector by PutValue().
virtual G4double GetLowEdgeEnergy(size_t binNumber) const;
// Obsolete method
// Get the energy value at the low edge of the specified bin.
// Take note that the 'binNumber' starts from '0'.
// This value is defined when a physics vector is constructed
// by a constructor of a derived class. Use this function
// when you fill physis vector by PutValue().
// This value should be defined before the call.
// The boundary check will not be done.
inline size_t GetVectorLength() const;
// Get the toal length (bin number) of the vector.
void FillSecondDerivatives();
// Initialise second derivatives for spline keeping
// 3d derivative continues - default algorithm
void ComputeSecDerivatives();
// Initialise second derivatives for spline using algorithm
// which garantee only 1st derivative continues
// Warning: this method should be called when the vector
// is already filled
void ComputeSecondDerivatives(G4double firstPointDerivative,
G4double endPointDerivative);
// Initialise second derivatives for spline using
// user defined 1st derivatives at edge points
// Warning: this method should be called when the vector
// is already filled
inline G4bool IsFilledVectorExist() const;
// Is non-empty physics vector already exist?
inline void PutComment(const G4String& theComment);
// Put a comment to the G4PhysicsVector. This may help to check
// whether your are accessing to the one you want.
inline const G4String& GetComment() const;
// Retrieve the comment of the G4PhysicsVector.
@@ -153,19 +189,23 @@ class G4PhysicsVector
G4PhysicsVectorType type; // The type of PhysicsVector (enumerator)
G4double edgeMin; // Lower edge value of the lowest bin
G4double edgeMax; // Lower edge value of the highest bin
size_t numberOfBin;
G4double edgeMin; // Energy of first point
G4double edgeMax; // Energy of the last point
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
G4PVDataVector dataVector; // Vector to keep the crossection/energyloss
G4PVDataVector binVector; // Vector to keep the low edge value of bin
G4PVDataVector binVector; // Vector to keep energy
G4PVDataVector secDerivative; // Vector to keep second derivatives
private:
G4bool SplinePossible();
inline G4double LinearInterpolation();
// Linear interpolation function
inline G4double SplineInterpolation();
@@ -173,11 +213,6 @@ class G4PhysicsVector
inline void Interpolation();
void FillSecondDerivatives();
// Initialise second derivatives for spline
G4double* secDerivative;
G4String comment;
G4bool useSpline;
};
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.icc,v 1.17 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsVector.icc,v 1.23 2009/11/18 11:42:03 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//---------------------------------------------------------------
@@ -58,10 +58,18 @@ inline
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::Energy(const size_t binNumber) const
{
return binVector[binNumber];
}
//---------------------------------------------------------------
inline
size_t G4PhysicsVector::GetVectorLength() const
{
return numberOfBin;
return numberOfNodes;
}
//---------------------------------------------------------------
@@ -93,21 +101,23 @@ inline
// the following interpolation is valid even the current locBin=
// numberOfBin-1.
if( !secDerivative ) { FillSecondDerivatives(); }
if(0 == secDerivative.size() ) { FillSecondDerivatives(); }
// check bin value
G4double delta = binVector[lastBin+1] - binVector[lastBin];
G4double x1 = binVector[lastBin];
G4double x2 = binVector[lastBin+1];
G4double delta = x2 - x1;
G4double a = (binVector[lastBin+1] - lastEnergy)/delta;
G4double b = (lastEnergy - binVector[lastBin])/delta;
G4double a = (x2 - lastEnergy)/delta;
G4double b = (lastEnergy - x1)/delta;
// Final evaluation of cubic spline polynomial for return
G4double y1 = dataVector[lastBin];
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 ;
( (a*a*a - a)*secDerivative[lastBin] +
(b*b*b - b)*secDerivative[lastBin+1] )*delta*delta/6.0;
return res;
}
@@ -116,6 +126,14 @@ inline
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
@@ -133,18 +151,14 @@ inline
lastEnergy = edgeMin;
lastValue = dataVector[0];
} else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin-1]) {
lastBin--;
lastEnergy = theEnergy;
Interpolation();
} else if( theEnergy >= edgeMax ){
lastBin = numberOfBin-1;
lastBin = numberOfNodes-2;
lastEnergy = edgeMax;
lastValue = dataVector[lastBin];
lastValue = dataVector[numberOfNodes-1];
} else {
lastBin = FindBinLocation(theEnergy);
if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;}
lastEnergy = theEnergy;
Interpolation();
}
@@ -166,11 +180,6 @@ inline
void G4PhysicsVector::PutValue(size_t binNumber, G4double theValue)
{
dataVector[binNumber] = theValue;
// Fill the bin which is hidden to user with theValue. This is to
// handle correctly when Energy=theEmax in getValue.
if(binNumber==numberOfBin-1) { dataVector[binNumber+1] = theValue; }
}
//---------------------------------------------------------------
@@ -180,7 +189,7 @@ inline
{
G4bool status=false;
if(numberOfBin > 0) { status=true; }
if(numberOfNodes > 0) { status=true; }
return status;
}
+190
View File
@@ -0,0 +1,190 @@
//
// ********************************************************************
// * 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: G4Pow.hh,v 1.2 2009/07/03 11:35:07 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// -------------------------------------------------------------------
//
// Class G4Pow
//
// Class description:
//
// Utility singleton class for the fast computation of log and pow
// functions
// Author: Vladimir Ivanchenko
//
// Creation date: 23.05.2009
// -------------------------------------------------------------------
#ifndef G4Pow_h
#define G4Pow_h 1
#include "globals.hh"
#include "G4DataVector.hh"
class G4Pow
{
public:
static G4Pow* GetInstance();
// Fast computation of Z^1/3
//
inline G4double Z13(G4int Z);
inline G4double A13(G4double A);
// Fast computation of Z^2/3
//
inline G4double Z23(G4int Z);
inline G4double A23(G4double A);
// Fast computation of log(Z)
//
inline G4double logZ(G4int Z);
inline G4double logA(G4double A);
// Fast computation of log10(Z)
//
inline G4double log10Z(G4int Z);
inline G4double log10A(G4double A);
// Fast computation of pow(Z,X)
//
inline G4double powZ(G4int Z, G4double y);
inline G4double powA(G4double A, G4double y);
// Fast factorial
//
inline G4double factorial(G4int Z);
private:
G4Pow();
~G4Pow();
private:
static G4Pow* fInstance;
G4double onethird;
G4DataVector pz13;
G4DataVector lz;
G4DataVector fact;
};
// -------------------------------------------------------------------
inline G4double G4Pow::Z13(G4int Z)
{
return pz13[Z];
}
inline G4double G4Pow::A13(G4double A)
{
const G4int maxZ = 256;
G4double res;
G4int i = G4int(A + 0.5);
if((i >= 1) && (i < maxZ))
{
G4double x = (1.0 - A/G4double(i))*onethird;
res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
}
else
{
res = std::pow(A, onethird);
}
return res;
}
inline G4double G4Pow::Z23(G4int Z)
{
G4double x = Z13(Z);
return x*x;
}
inline G4double G4Pow::A23(G4double A)
{
G4double x = A13(A);
return x*x;
}
inline G4double G4Pow::logZ(G4int Z)
{
return lz[Z];
}
inline G4double G4Pow::logA(G4double A)
{
const G4int maxZ = 256;
G4double res;
G4int i = G4int(A + 0.5);
if((i >= 1) && (i < maxZ))
{
G4double x = 1.0 - A/G4double(i);
res = lz[i] + x*(1.0 - 0.5*x + onethird*x*x);
}
else
{
res = std::log(A);
}
return res;
}
inline G4double G4Pow::log10Z(G4int Z)
{
return lz[Z]/lz[10];
}
inline G4double G4Pow::log10A(G4double A)
{
return logA(A)/lz[10];
}
inline G4double G4Pow::powZ(G4int Z, G4double y)
{
return std::exp(y*lz[Z]);
}
inline G4double G4Pow::powA(G4double A, G4double y)
{
return std::exp(y*logA(A));
}
inline G4double G4Pow::factorial(G4int Z)
{
return fact[Z];
}
// -------------------------------------------------------------------
#endif
+5 -11
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4String.hh,v 1.10 2008/12/08 14:16:05 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4String.hh,v 1.15 2009/08/10 10:18:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//---------------------------------------------------------------
@@ -77,9 +77,9 @@ public:
inline G4int operator!() const;
inline G4bool operator==(G4String) const;
inline G4bool operator==(const G4String&) const;
inline G4bool operator==(const char*) const;
inline G4bool operator!=(G4String) const;
inline G4bool operator!=(const G4String&) const;
inline G4bool operator!=(const char*) const;
inline str_size length() const;
@@ -137,7 +137,6 @@ public:
inline G4bool operator!=(const G4String&) const;
inline G4bool operator!=(const char*) const;
//inline G4String operator () (unsigned int, unsigned int);
inline operator const char*() const;
inline G4SubString operator()(str_size, str_size);
@@ -159,7 +158,7 @@ public:
inline G4int first(char) const;
inline G4int last(char) const;
inline G4bool contains(std::string) const;
inline G4bool contains(const std::string&) const;
inline G4bool contains(char) const;
// stripType = 0 beginning
@@ -183,11 +182,6 @@ public:
inline unsigned int hash( caseCompare cmp = exact ) const;
inline unsigned int stlhash() const;
// useful for supplying hash functions to template hash collection ctors
//
static inline unsigned int hash(const G4String&);
};
#include "G4String.icc"
+26 -50
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4String.icc,v 1.11 2008/12/08 14:16:05 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4String.icc,v 1.19 2009/08/10 10:30:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//---------------------------------------------------------------
@@ -90,27 +90,27 @@ char G4SubString::operator[](str_size i) const
G4int G4SubString::operator!() const
{
return extent==0 ? 1 : 0;
return (extent==0) ? 1 : 0;
}
G4bool G4SubString::operator==(G4String s) const
G4bool G4SubString::operator==(const G4String& s) const
{
return mystring->substr(mystart,extent) == s ? true:false;
return (mystring->find(s,mystart,extent) != std::string::npos);
}
G4bool G4SubString::operator==(const char* s) const
{
return mystring->substr(mystart,extent) == std::string(s) ? true:false;
return (mystring->find(s,mystart,extent) != std::string::npos);
}
G4bool G4SubString::operator!=(G4String s) const
G4bool G4SubString::operator!=(const G4String& s) const
{
return mystring->substr(mystart,extent) != std::string(s) ? true:false;
return (mystring->find(s,mystart,extent) == std::string::npos);
}
G4bool G4SubString::operator!=(const char* s) const
{
return mystring->substr(mystart,extent) != std::string(s) ? true:false;
return (mystring->find(s,mystart,extent) == std::string::npos);
}
str_size G4SubString::length() const
@@ -125,7 +125,7 @@ str_size G4SubString::start() const
G4bool G4SubString::isNull() const
{
return extent==0 ? true : false;
return (extent==0);
}
// **************************************************************
@@ -218,30 +218,22 @@ G4String& G4String::operator+=(const char &c)
G4bool G4String::operator==(const G4String &s) const
{
const std_string *a=this;
const std_string *b=&s;
return *a==*b;
return (std_string::compare(s) == 0);
}
G4bool G4String::operator==(const char* s) const
{
const std_string *a=this;
const std_string b=s;
return *a==b;
return (std_string::compare(s) == 0);
}
G4bool G4String::operator!=(const G4String &s) const
{
const std_string *a=this;
const std_string *b=&s;
return *a!=*b;
return !(*this == s);
}
G4bool G4String::operator!=(const char* s) const
{
const std_string *a=this;
const std_string b=s;
return *a!=b;
return !(*this == s);
}
G4String::operator const char*() const
@@ -267,18 +259,14 @@ G4int G4String::strcasecompare(const char* s1, const char* s2) const
G4int G4String::compareTo(const char* s, caseCompare mode)
{
if(mode==exact)
{ return strcmp(c_str(),s); }
else
{ return strcasecompare(c_str(),s); }
return (mode==exact) ? strcmp(c_str(),s)
: strcasecompare(c_str(),s);
}
G4int G4String::compareTo(const G4String& s, caseCompare mode)
{
if(mode==exact)
{ return strcmp(c_str(),s.c_str()); }
else
{ return strcasecompare(c_str(),s.c_str()); }
return (mode==exact) ? strcmp(c_str(),s.c_str())
: strcasecompare(c_str(),s.c_str());
}
G4String& G4String::prepend (const char* str)
@@ -297,12 +285,14 @@ std::istream&
G4String::readLine (std::istream& s, G4bool skipWhite)
{
char tmp[1024];
if ( skipWhite ) {
if ( skipWhite )
{
s >> std::ws;
s.getline(tmp,1024);
*this=tmp;
}
else {
else
{
s.getline(tmp,1024);
*this=tmp;
}
@@ -324,8 +314,7 @@ G4String& G4String::replace(str_size pos, str_size n, const char* s)
G4String& G4String::remove(str_size n)
{
if(n<size())
{ erase(n,size()-n); }
if(n<size()) { erase(n,size()-n); }
return *this;
}
@@ -345,22 +334,14 @@ G4int G4String::last(char c) const
return rfind(c);
}
G4bool G4String::contains(std::string s) const
G4bool G4String::contains(const std::string& s) const
{
G4int i=std_string::find(s);
if(i != G4int(std_string::npos))
{ return true; }
else
{ return false; }
return (std_string::find(s) != std_string::npos);
}
G4bool G4String::contains(char c) const
{
G4int i=std_string::find(c);
if(i != G4int(std_string::npos))
{ return true; }
else
{ return false; }
return (std_string::find(c) != std_string::npos);
}
G4String G4String::strip (G4int strip_Type, char c)
@@ -473,8 +454,3 @@ unsigned int G4String::stlhash() const
return str_size(h);
}
unsigned int G4String::hash(const G4String& s)
{
return s.hash();
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Version.hh,v 1.17 2008/12/02 09:15:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Version.hh,v 1.25 2009/11/24 13:51:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// Version information
//
@@ -46,18 +46,18 @@
// |--> patch number
#ifndef G4VERSION_NUMBER
#define G4VERSION_NUMBER 920
#define G4VERSION_NUMBER 930
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-09-02 $"
#define G4VERSION_TAG "$Name: geant4-09-03 $"
#endif
// as variables
#include "G4String.hh"
static const G4String G4Version = "$Name: geant4-09-02 $";
static const G4String G4Date = "(19-December-2008)";
static const G4String G4Version = "$Name: geant4-09-03 $";
static const G4String G4Date = "(18-December-2009)";
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ErrorPropagatorData.cc,v 1.3 2007/06/05 13:04:30 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ErrorPropagatorData.cc,v 1.5 2009/05/19 13:31:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------------
@@ -42,8 +42,14 @@ G4int G4ErrorPropagatorData::theVerbosity = 0;
//-------------------------------------------------------------------
G4ErrorPropagatorData::G4ErrorPropagatorData(){}
G4ErrorPropagatorData::~G4ErrorPropagatorData(){}
G4ErrorPropagatorData::~G4ErrorPropagatorData()
{
}
G4ErrorPropagatorData::G4ErrorPropagatorData()
{
theStage = G4ErrorStage_Inflation;
}
G4ErrorPropagatorData* G4ErrorPropagatorData::GetErrorPropagatorData()
{
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.cc,v 1.22 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4LPhysicsFreeVector.cc,v 1.23 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------------
@@ -34,11 +34,13 @@
// This is a free vector for Low Energy Physics cross section data
//
// F.W. Jones, TRIUMF, 04-JUN-96
//
// Modified:
// 19 Jun. 2009, V.Ivanchenko : removed hidden bin
//
// --------------------------------------------------------------------
#include "G4LPhysicsFreeVector.hh"
#include "G4ios.hh"
// --------------------------------------------------------------------
@@ -60,10 +62,10 @@ G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin,
edgeMin = binmin;
edgeMax = binmax;
numberOfBin = nbin;
binVector.reserve(nbin+1);
dataVector.reserve(nbin+1);
for (size_t i=0; i<=numberOfBin; i++)
numberOfNodes = nbin;
binVector.reserve(numberOfNodes);
dataVector.reserve(numberOfNodes);
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
@@ -104,7 +106,7 @@ G4LPhysicsFreeVector::operator=(const G4LPhysicsFreeVector& right)
void G4LPhysicsFreeVector::DumpValues()
{
for (size_t i = 0; i < numberOfBin; i++)
for (size_t i = 0; i < numberOfNodes; i++)
{
G4cout << binVector[i] << " " << dataVector[i]/millibarn << G4endl;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsFreeVector.cc,v 1.12 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsFreeVector.cc,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//--------------------------------------------------------------------
@@ -40,6 +40,7 @@
// user introduced
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added
// 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
// 19 Jun. 2009, V.Ivanchenko : removed hidden bin
//
//--------------------------------------------------------------------
@@ -56,14 +57,12 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
: G4PhysicsVector()
{
type = T_G4PhysicsFreeVector;
numberOfBin = theNbin;
numberOfNodes = theNbin;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(numberOfBin+1);
binVector.reserve(numberOfBin+1);
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
for (size_t i=0; i<=numberOfBin; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
@@ -74,32 +73,19 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
const G4DataVector& theDataVector)
{
type = T_G4PhysicsFreeVector;
numberOfBin = theBinVector.size();
numberOfNodes = theBinVector.size();
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(numberOfBin+1);
binVector.reserve(numberOfBin+1);
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
for (size_t i=0; i<numberOfBin; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(theBinVector[i]);
dataVector.push_back(theDataVector[i]);
}
// Put values to extra hidden bin. For 'binVector', the 'edgeMin' of the
// extra hidden bin is assumed to have the following value. For binary
// search, this value is completely arbitrary if it is greater than
// the 'edgeMin' at 'numberOfBin-1'.
binVector.push_back ( theBinVector[numberOfBin-1] + 1.0 );
// Put values to extra hidden bin. For 'dataVector', the 'value' of the
// extra hidden bin is assumed to have the same as the one at 'numberBin-1'.
dataVector.push_back( theDataVector[numberOfBin-1] );
edgeMin = binVector[0];
edgeMax = binVector[numberOfBin-1];
edgeMax = binVector[numberOfNodes-1];
}
G4PhysicsFreeVector::~G4PhysicsFreeVector()
@@ -112,20 +98,9 @@ void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue,
binVector[theBinNumber] = theBinValue;
dataVector[theBinNumber] = theDataValue;
if( theBinNumber == numberOfBin-1 )
if( theBinNumber == numberOfNodes-1 )
{
edgeMax = binVector[numberOfBin-1];
// Put values to extra hidden bin. For 'binVector', the 'edgeMin'
// of the extra hidden bin is assumed to have the following value.
// For binary search, this value is completely arbitrary if it is
// greater than the 'edgeMin' at 'numberOfBin-1'.
binVector[numberOfBin] = theBinValue + 1.0;
// Put values to extra hidden bin. For 'dataVector', the 'value'
// of the extra hidden bin is assumed to have the same as the one
// at 'numberBin-1'.
dataVector[numberOfBin] = theDataValue;
edgeMax = binVector[numberOfNodes-1];
}
if( theBinNumber == 0 )
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLinearVector.cc,v 1.14 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLinearVector.cc,v 1.15 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
//--------------------------------------------------------------------
@@ -34,6 +34,7 @@
// G4PhysicsLinearVector.cc
//
// 15 Feb 1996 - K.Amako : 1st version
// 19 Jun 2009 - V.Ivanchenko : removed hidden bin
//
//--------------------------------------------------------------------
@@ -50,14 +51,11 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
{
type = T_G4PhysicsLinearVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
numberOfBin = theNbin;
for (size_t i=0; i<=numberOfBin; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
@@ -72,21 +70,18 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
{
type = T_G4PhysicsLinearVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
numberOfBin = theNbin;
for (size_t i=0; i<numberOfBin+1; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back( theEmin + i*dBin );
dataVector.push_back(0.0);
}
edgeMin = binVector[0];
edgeMax = binVector[numberOfBin-1];
edgeMax = binVector[numberOfNodes-1];
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLnVector.cc,v 1.17 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLnVector.cc,v 1.18 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------
@@ -34,6 +34,7 @@
// G4PhysicsLnVector.cc
//
// 27 Apr 1999 - M.G.Pia: Created from G4PhysicsLogVector
// 19 Jun 2009 - V.Ivanchenko : removed hidden bin
//
// --------------------------------------------------------------
@@ -50,14 +51,11 @@ G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
{
type = T_G4PhysicsLnVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
numberOfBin = theNbin;
for (size_t i=0; i<=numberOfBin; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
@@ -72,21 +70,18 @@ G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin,
{
type = T_G4PhysicsLnVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
numberOfBin = theNbin;
for (size_t i=0; i<numberOfBin+1; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(std::exp(std::log(theEmin)+i*dBin));
binVector.push_back(std::exp((baseBin+i)*dBin));
dataVector.push_back(0.0);
}
edgeMin = binVector[0];
edgeMax = binVector[numberOfBin-1];
edgeMax = binVector[numberOfNodes-1];
}
G4PhysicsLnVector::~G4PhysicsLnVector(){}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLogVector.cc,v 1.21 2008/09/22 08:26:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsLogVector.cc,v 1.22 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------
@@ -41,6 +41,7 @@
// 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
// 9 Mar. 2001, H.Kurashige : added PhysicsVector type and Retrieve
// 05 Sep. 2008, V.Ivanchenko : added protections for zero-length vector
// 19 Jun. 2009, V.Ivanchenko : removed hidden bin
//
// --------------------------------------------------------------
@@ -57,14 +58,11 @@ G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
{
type = T_G4PhysicsLogVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
numberOfBin = theNbin;
for (size_t i=0; i<=numberOfBin; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
@@ -78,20 +76,19 @@ G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
{
type = T_G4PhysicsLogVector;
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.reserve(theNbin+1);
binVector.reserve(theNbin+1);
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
static const G4double g4log10 = std::log(10.);
numberOfBin = theNbin;
for (size_t i=0; i<numberOfBin+1; i++)
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(std::pow(10., std::log10(theEmin)+i*dBin));
binVector.push_back(std::exp(g4log10*(baseBin+i)*dBin));
dataVector.push_back(0.0);
}
edgeMin = binVector[0];
edgeMax = binVector[numberOfBin-1];
edgeMax = binVector[numberOfNodes-1];
}
G4PhysicsLogVector::~G4PhysicsLogVector()
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.12 2008/09/22 14:49:57 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Implementation
@@ -42,8 +42,10 @@
// derived class constructors
// 2000-11-11 by H.Kurashige
// > use STL vector for dataVector and binVector
// mail: gum@triumf.ca
// 19 Jun. 2009-06-19 by V.Ivanchenko
// > removed hidden bin
//
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
@@ -64,19 +66,17 @@ G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
{
type = T_G4PhysicsOrderedFreeVector;
dataVector.reserve(VectorLength+1);
binVector.reserve(VectorLength+1);
numberOfBin = VectorLength;
dataVector.reserve(VectorLength);
binVector.reserve(VectorLength);
numberOfNodes = VectorLength;
for (size_t i = 0 ; i < VectorLength ; i++)
{
binVector.push_back(Energies[i]);
dataVector.push_back(Values[i]);
}
edgeMin = binVector.front();
edgeMax = binVector.back();
binVector.push_back ( binVector[numberOfBin-1] + 1.0 );
dataVector.push_back( dataVector[numberOfBin-1] );
edgeMin = binVector[0];
edgeMax = binVector[numberOfNodes-1];
}
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
@@ -100,7 +100,7 @@ G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
{
binVector.push_back(energy);
dataVector.push_back(value);
numberOfBin++;
numberOfNodes++;
edgeMin = binVector.front();
edgeMax = binVector.back();
@@ -132,8 +132,8 @@ size_t
G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
G4int n2 = numberOfNodes/2;
G4int n3 = numberOfNodes - 1;
while (n1 != n3 - 1) {
if (aValue > dataVector[n2])
{ n1 = n2; }
+211 -41
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.cc,v 1.27 2008/10/16 12:14:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicsVector.cc,v 1.41 2009/12/07 09:21:27 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// --------------------------------------------------------------
@@ -42,6 +42,12 @@
// 18 Jan. 2001, H.Kurashige : removed ptrNextTable
// 09 Mar. 2001, H.Kurashige : added G4PhysicsVector type
// 05 Sep. 2008, V.Ivanchenko : added protections for zero-length vector
// 11 May 2009, A.Bagulya : added new implementation of methods
// ComputeSecondDerivatives - first derivatives at edge points
// should be provided by a user
// FillSecondDerivatives - default computation base on "not-a-knot"
// algorithm
// 19 Jun. 2009, V.Ivanchenko : removed hidden bin
// --------------------------------------------------------------
#include "G4PhysicsVector.hh"
@@ -51,17 +57,14 @@
G4PhysicsVector::G4PhysicsVector(G4bool spline)
: type(T_G4PhysicsVector),
edgeMin(0.), edgeMax(0.), numberOfBin(0),
lastEnergy(0.), lastValue(0.), lastBin(0),
secDerivative(0), useSpline(spline)
edgeMin(0.), edgeMax(0.), numberOfNodes(0),
lastEnergy(-DBL_MAX), lastValue(0.), lastBin(0), useSpline(spline)
{}
// --------------------------------------------------------------
G4PhysicsVector::~G4PhysicsVector()
{
DeleteData();
}
{}
// --------------------------------------------------------------
@@ -77,7 +80,7 @@ G4PhysicsVector& G4PhysicsVector::operator=(const G4PhysicsVector& right)
if (&right==this) { return *this; }
if (type != right.type) { return *this; }
DeleteData();
//DeleteData();
CopyData(right);
return *this;
@@ -101,8 +104,7 @@ G4int G4PhysicsVector::operator!=(const G4PhysicsVector &right) const
void G4PhysicsVector::DeleteData()
{
delete [] secDerivative;
secDerivative = 0;
secDerivative.clear();
}
// --------------------------------------------------------------
@@ -112,7 +114,7 @@ void G4PhysicsVector::CopyData(const G4PhysicsVector& vec)
type = vec.type;
edgeMin = vec.edgeMin;
edgeMax = vec.edgeMax;
numberOfBin = vec.numberOfBin;
numberOfNodes = vec.numberOfNodes;
lastEnergy = vec.lastEnergy;
lastValue = vec.lastValue;
lastBin = vec.lastBin;
@@ -120,18 +122,7 @@ void G4PhysicsVector::CopyData(const G4PhysicsVector& vec)
binVector = vec.binVector;
useSpline = vec.useSpline;
comment = vec.comment;
if (vec.secDerivative)
{
secDerivative = new G4double [numberOfBin];
for (size_t i=0; i<numberOfBin; i++)
{
secDerivative[i] = vec.secDerivative[i];
}
}
else
{
secDerivative = 0;
}
secDerivative = vec.secDerivative;
}
// --------------------------------------------------------------
@@ -156,14 +147,14 @@ G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii)
// binning
fOut.write((char*)(&edgeMin), sizeof edgeMin);
fOut.write((char*)(&edgeMax), sizeof edgeMax);
fOut.write((char*)(&numberOfBin), sizeof numberOfBin);
fOut.write((char*)(&numberOfNodes), sizeof numberOfNodes);
// contents
size_t size = dataVector.size();
fOut.write((char*)(&size), sizeof size);
G4double* value = new G4double[2*size];
for(size_t i = 0; i < size; i++)
for(size_t i = 0; i < size; ++i)
{
value[2*i] = binVector[i];
value[2*i+1]= dataVector[i];
@@ -179,18 +170,19 @@ G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii)
G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
// clear properties;
lastEnergy=0.;
lastEnergy=-DBL_MAX;
lastValue =0.;
lastBin =0;
dataVector.clear();
binVector.clear();
secDerivative.clear();
comment = "";
// retrieve in ascii mode
if (ascii)
{
// binning
fIn >> edgeMin >> edgeMax >> numberOfBin;
fIn >> edgeMin >> edgeMax >> numberOfNodes;
if (fIn.fail()) { return false; }
// contents
size_t size=0;
@@ -217,7 +209,7 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
// binning
fIn.read((char*)(&edgeMin), sizeof edgeMin);
fIn.read((char*)(&edgeMax), sizeof edgeMax);
fIn.read((char*)(&numberOfBin), sizeof numberOfBin );
fIn.read((char*)(&numberOfNodes), sizeof numberOfNodes );
// contents
size_t size;
@@ -233,7 +225,7 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
binVector.reserve(size);
dataVector.reserve(size);
for(size_t i = 0; i < size; i++)
for(size_t i = 0; i < size; ++i)
{
binVector.push_back(value[2*i]);
dataVector.push_back(value[2*i+1]);
@@ -244,23 +236,181 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
// --------------------------------------------------------------
void G4PhysicsVector::FillSecondDerivatives()
{
secDerivative = new G4double [numberOfBin];
void
G4PhysicsVector::ScaleVector(G4double factorE, G4double factorV)
{
size_t n = dataVector.size();
size_t i;
if(n > 0) {
for(i=0; i<n; ++i) {
binVector[i] *= factorE;
dataVector[i] *= factorV;
}
}
n = secDerivative.size();
if(n > 0) { for(i=0; i<n; ++i) { secDerivative[i] *= factorV; } }
size_t n = numberOfBin-1;
edgeMin *= factorE;
edgeMax *= factorE;
lastEnergy *= factorE;
lastValue *= factorV;
}
// cannot compute derivatives for less than 3 points
if(3 > numberOfBin)
// --------------------------------------------------------------
void
G4PhysicsVector::ComputeSecondDerivatives(G4double firstPointDerivative,
G4double endPointDerivative)
// A standard method of computation of second derivatives
// First derivatives at the first and the last point should be provided
// See for example W.H. Press et al. "Numerical reciptes and C"
// Cambridge University Press, 1997.
{
if(4 > numberOfNodes) // cannot compute derivatives for less than 4 bins
{
secDerivative[0] = 0.0;
secDerivative[n] = 0.0;
ComputeSecDerivatives();
return;
}
for(size_t i=1; i<n; i++)
if(!SplinePossible()) { return; }
G4int n = numberOfNodes-1;
G4double* u = new G4double [n];
G4double p, sig, un;
u[0] = (6.0/(binVector[1]-binVector[0]))
* ((dataVector[1]-dataVector[0])/(binVector[1]-binVector[0])
- firstPointDerivative);
secDerivative[0] = - 0.5;
// Decomposition loop for tridiagonal algorithm. secDerivative[i]
// and u[i] are used for temporary storage of the decomposed factors.
for(G4int i=1; i<n; ++i)
{
secDerivative[i] =
sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
p = sig*secDerivative[i-1] + 2.0;
secDerivative[i] = (sig - 1.0)/p;
u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
- (dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]);
u[i] = 6.0*u[i]/(binVector[i+1]-binVector[i-1]) - sig*u[i-1]/p;
}
sig = (binVector[n-1]-binVector[n-2]) / (binVector[n]-binVector[n-2]);
p = sig*secDerivative[n-2] + 2.0;
un = (6.0/(binVector[n]-binVector[n-1]))
*(endPointDerivative -
(dataVector[n]-dataVector[n-1])/(binVector[n]-binVector[n-1])) - u[n-1]/p;
secDerivative[n] = un/(secDerivative[n-1] + 2.0);
// The back-substitution loop for the triagonal algorithm of solving
// a linear system of equations.
for(G4int k=n-1; k>0; --k)
{
secDerivative[k] *=
(secDerivative[k+1] -
u[k]*(binVector[k+1]-binVector[k-1])/(binVector[k+1]-binVector[k]));
}
secDerivative[0] = 0.5*(u[0] - secDerivative[1]);
delete [] u;
}
// --------------------------------------------------------------
void G4PhysicsVector::FillSecondDerivatives()
// Computation of second derivatives using "Not-a-knot" endpoint conditions
// B.I. Kvasov "Methods of shape-preserving spline approximation"
// World Scientific, 2000
{
if(5 > numberOfNodes) // cannot compute derivatives for less than 4 points
{
ComputeSecDerivatives();
return;
}
if(!SplinePossible()) { return; }
G4int n = numberOfNodes-1;
//G4cout << "G4PhysicsVector::FillSecondDerivatives() n= " << n << G4endl;
// G4cout << *this << G4endl;
G4double* u = new G4double [n];
G4double p, sig;
u[1] = ((dataVector[2]-dataVector[1])/(binVector[2]-binVector[1]) -
(dataVector[1]-dataVector[0])/(binVector[1]-binVector[0]));
u[1] = 6.0*u[1]*(binVector[2]-binVector[1])
/ ((binVector[2]-binVector[0])*(binVector[2]-binVector[0]));
// Decomposition loop for tridiagonal algorithm. secDerivative[i]
// and u[i] are used for temporary storage of the decomposed factors.
secDerivative[1] = (2.0*binVector[1]-binVector[0]-binVector[2])
/ (2.0*binVector[2]-binVector[0]-binVector[1]);
for(G4int i=2; i<n-1; ++i)
{
sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
p = sig*secDerivative[i-1] + 2.0;
secDerivative[i] = (sig - 1.0)/p;
u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
- (dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]);
u[i] = (6.0*u[i]/(binVector[i+1]-binVector[i-1])) - sig*u[i-1]/p;
}
sig = (binVector[n-1]-binVector[n-2]) / (binVector[n]-binVector[n-2]);
p = sig*secDerivative[n-3] + 2.0;
u[n-1] = (dataVector[n]-dataVector[n-1])/(binVector[n]-binVector[n-1])
- (dataVector[n-1]-dataVector[n-2])/(binVector[n-1]-binVector[n-2]);
u[n-1] = 6.0*sig*u[n-1]/(binVector[n]-binVector[n-2])
- (2.0*sig - 1.0)*u[n-2]/p;
p = (1.0+sig) + (2.0*sig-1.0)*secDerivative[n-2];
secDerivative[n-1] = u[n-1]/p;
// The back-substitution loop for the triagonal algorithm of solving
// a linear system of equations.
for(G4int k=n-2; k>1; --k)
{
secDerivative[k] *=
(secDerivative[k+1] -
u[k]*(binVector[k+1]-binVector[k-1])/(binVector[k+1]-binVector[k]));
}
secDerivative[n] = (secDerivative[n-1] - (1.0-sig)*secDerivative[n-2])/sig;
sig = 1.0 - ((binVector[2]-binVector[1])/(binVector[2]-binVector[0]));
secDerivative[1] *= (secDerivative[2] - u[1]/(1.0-sig));
secDerivative[0] = (secDerivative[1] - sig*secDerivative[2])/(1.0-sig);
delete [] u;
}
// --------------------------------------------------------------
void
G4PhysicsVector::ComputeSecDerivatives()
// A simplified method of computation of second derivatives
{
if(!SplinePossible()) { return; }
if(3 > numberOfNodes) // cannot compute derivatives for less than 4 bins
{
useSpline = false;
return;
}
size_t n = numberOfNodes-1;
for(size_t i=1; i<n; ++i)
{
secDerivative[i] =
3.0*((dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i]) -
(dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]))
/(binVector[i+1]-binVector[i-1]);
@@ -268,6 +418,26 @@ void G4PhysicsVector::FillSecondDerivatives()
secDerivative[n] = secDerivative[n-1];
secDerivative[0] = secDerivative[1];
}
// --------------------------------------------------------------
G4bool G4PhysicsVector::SplinePossible()
// Initialise second derivative array. If neighbor energy coincide
// or not ordered than spline cannot be applied
{
if(!useSpline) return useSpline;
secDerivative.clear();
secDerivative.reserve(numberOfNodes);
for(size_t j=0; j<numberOfNodes; ++j)
{
secDerivative.push_back(0.0);
if(j > 0)
{
if(binVector[j]-binVector[j-1] <= 0.) { useSpline = false; }
}
}
return useSpline;
}
// --------------------------------------------------------------
@@ -275,7 +445,7 @@ std::ostream& operator<<(std::ostream& out, const G4PhysicsVector& pv)
{
// binning
out << std::setprecision(12) << pv.edgeMin;
out <<" " << pv.edgeMax <<" " << pv.numberOfBin << G4endl;
out <<" " << pv.edgeMax <<" " << pv.numberOfNodes << G4endl;
// contents
out << pv.dataVector.size() << G4endl;
+87
View File
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * 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: G4Pow.cc,v 1.2 2009/07/03 11:35:06 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
// GEANT4 Class file
//
//
// File name: G4Pow
//
// Author: Vladimir Ivanchenko
//
// Creation date: 23.05.2009
//
// -------------------------------------------------------------------
#include "G4Pow.hh"
G4Pow* G4Pow::fInstance = 0;
// -------------------------------------------------------------------
G4Pow* G4Pow::GetInstance()
{
if (fInstance == 0)
{
static G4Pow manager;
fInstance = &manager;
}
return fInstance;
}
// -------------------------------------------------------------------
G4Pow::G4Pow()
{
const G4int maxZ = 256;
pz13.resize(maxZ,0.0);
lz.resize(maxZ,0.0);
fact.resize(maxZ,0.0);
onethird = 1.0/3.0;
G4double f = 1.0;
for(G4int i=1; i<maxZ; i++)
{
G4double x = G4double(i);
pz13[i] = std::pow(x,onethird);
lz[i] = std::log(x);
f *= x;
fact[i] = f;
}
fact[0] = 1.0;
}
// -------------------------------------------------------------------
G4Pow::~G4Pow()
{}
// -------------------------------------------------------------------