Import Geant4 3.1.0 source tree
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Exception.cc,v 1.9 2000/07/22 10:45:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4LPhysicsFreeVector.cc,v 1.3 2000/11/20 17:26:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4LPhysicsFreeVector.cc,v 1.7 2001/03/09 03:39:30 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -17,6 +17,7 @@
|
||||
// F.W. Jones, TRIUMF, 04-JUN-96
|
||||
//
|
||||
// 27-MAR-97 FWJ: first version for Alpha release
|
||||
// 11-NOV-00 H.Kurashige : use STL vector for dataVector and binVector
|
||||
//
|
||||
|
||||
#include "G4LPhysicsFreeVector.hh"
|
||||
@@ -25,7 +26,8 @@
|
||||
|
||||
G4LPhysicsFreeVector::G4LPhysicsFreeVector()
|
||||
{
|
||||
ptrNextTable = 0;
|
||||
type = T_G4LPhysicsFreeVector;
|
||||
|
||||
edgeMin = 0.0;
|
||||
edgeMax = 0.0;
|
||||
numberOfBin = 0;
|
||||
@@ -35,16 +37,21 @@ G4LPhysicsFreeVector::G4LPhysicsFreeVector()
|
||||
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin, G4double binmin,
|
||||
G4double binmax)
|
||||
{
|
||||
type = T_G4LPhysicsFreeVector;
|
||||
|
||||
edgeMin = binmin;
|
||||
edgeMax = binmax;
|
||||
numberOfBin = nbin;
|
||||
lastEnergy = 0.;
|
||||
lastValue = 0.;
|
||||
lastBin = 0;
|
||||
binVector.resize(nbin);
|
||||
dataVector.resize(nbin);
|
||||
ptrNextTable = 0;
|
||||
binVector.reserve(nbin);
|
||||
dataVector.reserve(nbin);
|
||||
verboseLevel = 0;
|
||||
for (size_t i=0; i<numberOfBin; i++) {
|
||||
binVector.push_back(0.0);
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
G4LPhysicsFreeVector::~G4LPhysicsFreeVector()
|
||||
@@ -54,7 +61,7 @@ G4LPhysicsFreeVector::~G4LPhysicsFreeVector()
|
||||
void G4LPhysicsFreeVector::DumpValues()
|
||||
{
|
||||
for (size_t i = 0; i < numberOfBin; i++) {
|
||||
// printf(" %12.4f %7.1f\n", binVector(i), dataVector(i)*1.e-27);
|
||||
printf(" %12.4f %7.1f\n", binVector(i), dataVector(i)/millibarn);
|
||||
// printf(" %12.4f %7.1f\n", binVector[i], dataVector[i]*1.e-27);
|
||||
printf(" %12.4f %7.1f\n", binVector[i], dataVector[i]/millibarn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsFreeVector.cc,v 1.3 2000/11/20 17:26:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsFreeVector.cc,v 1.7 2001/03/09 03:39:30 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
@@ -16,10 +16,11 @@
|
||||
//
|
||||
// History:
|
||||
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
|
||||
// 06 June 1996, K.Amako : The 1st version of implemented.
|
||||
// 06 June 1996, K.Amako : The 1st version of implemented
|
||||
// 01 Jul. 1996, K.Amako : Cache mechanism and hidden bin from the
|
||||
// user introduced.
|
||||
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added.
|
||||
// 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
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@@ -28,23 +29,27 @@
|
||||
|
||||
G4PhysicsFreeVector::G4PhysicsFreeVector()
|
||||
{
|
||||
ptrNextTable = 0;
|
||||
edgeMin = 0.0;
|
||||
edgeMax = 0.0;
|
||||
numberOfBin = 0;
|
||||
type = T_G4PhysicsFreeVector;
|
||||
}
|
||||
|
||||
|
||||
G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsFreeVector;
|
||||
numberOfBin = theNbin;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(numberOfBin+1);
|
||||
binVector.resize(numberOfBin+1);
|
||||
dataVector.reserve(numberOfBin+1);
|
||||
binVector.reserve(numberOfBin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
for (size_t i=0; i<=numberOfBin; i++) {
|
||||
binVector.push_back(0.0);
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
|
||||
edgeMin = 0.;
|
||||
edgeMax = 0.;
|
||||
@@ -59,33 +64,32 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
|
||||
G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
|
||||
const G4DataVector& theDataVector)
|
||||
{
|
||||
numberOfBin = theBinVector.entries();
|
||||
type = T_G4PhysicsFreeVector;
|
||||
numberOfBin = theBinVector.size();
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(numberOfBin+1);
|
||||
binVector.resize(numberOfBin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
dataVector.reserve(numberOfBin+1);
|
||||
binVector.reserve(numberOfBin+1);
|
||||
|
||||
for (size_t i=0; i<numberOfBin; i++) {
|
||||
binVector(i) = theBinVector(i);
|
||||
dataVector(i) = theDataVector(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(numberOfBin) = theBinVector(numberOfBin-1) + 1.0;
|
||||
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(numberOfBin) = theDataVector(numberOfBin-1);
|
||||
dataVector.push_back( theDataVector[numberOfBin-1] );
|
||||
|
||||
edgeMin = binVector(0);
|
||||
edgeMax = binVector(numberOfBin-1);
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfBin-1];
|
||||
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
@@ -100,26 +104,26 @@ G4PhysicsFreeVector::~G4PhysicsFreeVector(){}
|
||||
void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue,
|
||||
G4double theDataValue )
|
||||
{
|
||||
binVector(theBinNumber) = theBinValue;
|
||||
dataVector(theBinNumber) = theDataValue;
|
||||
binVector[theBinNumber] = theBinValue;
|
||||
dataVector[theBinNumber] = theDataValue;
|
||||
|
||||
|
||||
if( theBinNumber == numberOfBin-1 ) {
|
||||
edgeMax = binVector(numberOfBin-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;
|
||||
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;
|
||||
dataVector[numberOfBin] = theDataValue;
|
||||
}
|
||||
|
||||
if( theBinNumber == 0 ) {
|
||||
edgeMin = binVector(0);
|
||||
edgeMin = binVector[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsLinearVector.cc,v 1.3 2000/11/20 17:26:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsLinearVector.cc,v 1.8 2001/04/03 09:15:24 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
@@ -14,12 +14,14 @@
|
||||
//
|
||||
// G4PhysicsLinearVector.cc
|
||||
//
|
||||
// History: first implementation, based on object model of
|
||||
// History:
|
||||
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
|
||||
// 15 Feb. 1996, K.Amako : Implemented the 1st version
|
||||
// 01 Jul. 1996, K.Amako : Cache mechanism and hidden bin from the
|
||||
// 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
|
||||
// 9 Mar. 2001, H.Kurashige : add PhysicsVector type and Retrieve
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@@ -27,21 +29,21 @@
|
||||
|
||||
G4PhysicsLinearVector::G4PhysicsLinearVector()
|
||||
{
|
||||
ptrNextTable = 0;
|
||||
edgeMin = 0.0;
|
||||
edgeMax = 0.0;
|
||||
numberOfBin = 0;
|
||||
type = T_G4PhysicsLinearVector;
|
||||
}
|
||||
|
||||
G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLinearVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = 0.;
|
||||
baseBin = 0.;
|
||||
@@ -52,28 +54,34 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
lastValue = DBL_MAX;
|
||||
|
||||
for (size_t i=0; i<=numberOfBin; i++) {
|
||||
binVector.push_back(0.0);
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
|
||||
G4double theEmax, size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLinearVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = (theEmax-theEmin) / numberOfBin;
|
||||
baseBin = theEmin/dBin;
|
||||
|
||||
for (size_t i=0; i<numberOfBin+1; i++) {
|
||||
binVector(i) = theEmin + i*dBin;
|
||||
binVector.push_back( theEmin + i*dBin );
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
|
||||
edgeMin = binVector(0);
|
||||
edgeMax = binVector(numberOfBin-1);
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfBin-1];
|
||||
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
@@ -81,3 +89,16 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
|
||||
}
|
||||
|
||||
G4PhysicsLinearVector::~G4PhysicsLinearVector(){}
|
||||
|
||||
|
||||
G4bool G4PhysicsLinearVector::Retrieve(G4std::ifstream& fIn, G4bool ascii)
|
||||
{
|
||||
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
|
||||
if (success){
|
||||
G4double theEmin = binVector[0];
|
||||
dBin = binVector[1]-theEmin;
|
||||
baseBin = theEmin/dBin;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsLnVector.cc,v 1.4 2000/11/20 17:26:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsLnVector.cc,v 1.10 2001/04/03 09:15:24 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
@@ -16,26 +16,29 @@
|
||||
//
|
||||
// History:
|
||||
// 27 Apr. 1999, M.G. Pia: Created, copying from G4PhysicsLogVector
|
||||
// 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
|
||||
// 9 Mar. 2001, H.Kurashige : add PhysicsVector type and Retrieve
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "G4PhysicsLnVector.hh"
|
||||
|
||||
|
||||
G4PhysicsLnVector::G4PhysicsLnVector()
|
||||
: dBin(0.), baseBin(0.)
|
||||
{}
|
||||
{
|
||||
type = T_G4PhysicsLnVector;
|
||||
}
|
||||
|
||||
|
||||
G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLnVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = 0.;
|
||||
baseBin = 0.;
|
||||
@@ -46,29 +49,35 @@ G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
lastValue = DBL_MAX;
|
||||
}
|
||||
|
||||
for (size_t i=0; i<=numberOfBin; i++) {
|
||||
binVector.push_back(0.0);
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin,
|
||||
G4double theEmax, size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLnVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = log(theEmax/theEmin) / numberOfBin;
|
||||
baseBin = log(theEmin)/dBin;
|
||||
|
||||
for (size_t i=0; i<numberOfBin+1; i++) {
|
||||
binVector(i) = exp(log(theEmin)+i*dBin);
|
||||
binVector.push_back(exp(log(theEmin)+i*dBin));
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
|
||||
edgeMin = binVector(0);
|
||||
edgeMax = binVector(numberOfBin-1);
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfBin-1];
|
||||
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
@@ -77,3 +86,15 @@ G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin,
|
||||
|
||||
|
||||
G4PhysicsLnVector::~G4PhysicsLnVector(){}
|
||||
|
||||
G4bool G4PhysicsLnVector::Retrieve(G4std::ifstream& fIn, G4bool ascii)
|
||||
{
|
||||
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
|
||||
if (success){
|
||||
G4double theEmin = binVector[0];
|
||||
dBin = log(binVector[1]/theEmin);
|
||||
baseBin = log(theEmin)/dBin;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsLogVector.cc,v 1.3 2000/11/20 17:26:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsLogVector.cc,v 1.8 2001/04/03 09:15:24 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
@@ -14,11 +14,13 @@
|
||||
//
|
||||
// G4PhysicsLogVector.cc
|
||||
//
|
||||
// History: first implementation, based on object model of
|
||||
// History:
|
||||
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
|
||||
// 15 Feb. 1996, K.Amako : Implemented the 1st version
|
||||
// 01 Jul. 1996, K.Amako : Hidden bin from the user introduced
|
||||
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added.
|
||||
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added
|
||||
// 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
|
||||
// 9 Mar. 2001, H.Kurashige : add PhysicsVector type and Retrieve
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
@@ -27,18 +29,20 @@
|
||||
|
||||
G4PhysicsLogVector::G4PhysicsLogVector()
|
||||
: dBin(0.), baseBin(0.)
|
||||
{}
|
||||
{
|
||||
type = T_G4PhysicsLogVector;
|
||||
}
|
||||
|
||||
|
||||
G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLogVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = 0.;
|
||||
baseBin = 0.;
|
||||
@@ -49,29 +53,35 @@ G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
lastValue = DBL_MAX;
|
||||
|
||||
for (size_t i=0; i<=numberOfBin; i++) {
|
||||
binVector.push_back(0.0);
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
|
||||
G4double theEmax, size_t theNbin)
|
||||
{
|
||||
type = T_G4PhysicsLogVector;
|
||||
|
||||
// Add extra one bin (hidden to user) to handle correctly when
|
||||
// Energy=theEmax in getValue.
|
||||
dataVector.resize(theNbin+1);
|
||||
binVector.resize(theNbin+1);
|
||||
dataVector.reserve(theNbin+1);
|
||||
binVector.reserve(theNbin+1);
|
||||
|
||||
ptrNextTable = 0;
|
||||
numberOfBin = theNbin;
|
||||
dBin = log10(theEmax/theEmin) / numberOfBin;
|
||||
baseBin = log10(theEmin)/dBin;
|
||||
|
||||
for (size_t i=0; i<numberOfBin+1; i++) {
|
||||
binVector(i) = pow(10., log10(theEmin)+i*dBin);
|
||||
binVector.push_back(pow(10., log10(theEmin)+i*dBin));
|
||||
dataVector.push_back(0.0);
|
||||
}
|
||||
|
||||
edgeMin = binVector(0);
|
||||
edgeMax = binVector(numberOfBin-1);
|
||||
edgeMin = binVector[0];
|
||||
edgeMax = binVector[numberOfBin-1];
|
||||
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
@@ -80,3 +90,15 @@ G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
|
||||
|
||||
|
||||
G4PhysicsLogVector::~G4PhysicsLogVector(){}
|
||||
|
||||
G4bool G4PhysicsLogVector::Retrieve(G4std::ifstream& fIn, G4bool ascii)
|
||||
{
|
||||
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
|
||||
if (success){
|
||||
G4double theEmin = binVector[0];
|
||||
dBin = log10(binVector[1]/theEmin);
|
||||
baseBin = log10(theEmin)/dBin;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.3 2000/11/20 17:26:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.7 2001/03/09 03:39:31 kurasige Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// PhysicsOrderedFreeVector Class Implementation
|
||||
@@ -21,6 +21,8 @@
|
||||
// 1998-11-11 by Peter Gumplinger
|
||||
// > initialize all data members of the base class in
|
||||
// derived class constructors
|
||||
// 2000-11-11 by H.Kurashige
|
||||
// > use STL vector for dataVector and binVector
|
||||
// mail: gum@triumf.ca
|
||||
//
|
||||
//
|
||||
@@ -40,8 +42,7 @@ G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
|
||||
G4double *Values,
|
||||
size_t VectorLength)
|
||||
{
|
||||
|
||||
ptrNextTable = 0;
|
||||
type = T_G4PhysicsOrderedFreeVector;
|
||||
|
||||
lastBin = INT_MAX;
|
||||
|
||||
@@ -52,16 +53,16 @@ G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
|
||||
|
||||
for (size_t i = 0 ; i < VectorLength ; i++)
|
||||
{
|
||||
binVector.insert(Energies[i]);
|
||||
dataVector.insert(Values[i]);
|
||||
binVector.push_back(Energies[i]);
|
||||
dataVector.push_back(Values[i]);
|
||||
}
|
||||
edgeMin = binVector.first();
|
||||
edgeMax = binVector.last();
|
||||
edgeMin = binVector.front();
|
||||
edgeMax = binVector.back();
|
||||
}
|
||||
|
||||
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
|
||||
{
|
||||
ptrNextTable = 0;
|
||||
type = T_G4PhysicsOrderedFreeVector;
|
||||
|
||||
lastBin = INT_MAX;
|
||||
lastEnergy = -DBL_MAX;
|
||||
@@ -85,11 +86,11 @@ G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector() {}
|
||||
void
|
||||
G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
|
||||
{
|
||||
binVector.insert(energy);
|
||||
dataVector.insert(value);
|
||||
binVector.push_back(energy);
|
||||
dataVector.push_back(value);
|
||||
numberOfBin++;
|
||||
edgeMin = binVector.first();
|
||||
edgeMax = binVector.last();
|
||||
edgeMin = binVector.front();
|
||||
edgeMax = binVector.back();
|
||||
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
|
||||
G4int n2 = numberOfBin/2;
|
||||
G4int n3 = numberOfBin - 1;
|
||||
while (n1 != n3 - 1) {
|
||||
if (aValue > dataVector(n2))
|
||||
if (aValue > dataVector[n2])
|
||||
n1 = n2;
|
||||
else
|
||||
n3 = n2;
|
||||
@@ -135,9 +136,9 @@ G4double
|
||||
G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(G4double aValue,
|
||||
size_t theLocBin)
|
||||
{
|
||||
G4double intplFactor = (aValue-dataVector(theLocBin))
|
||||
/ (dataVector(theLocBin+1)-dataVector(theLocBin)); // Interpolation factor
|
||||
G4double intplFactor = (aValue-dataVector[theLocBin])
|
||||
/ (dataVector[theLocBin+1]-dataVector[theLocBin]); // Interpolation factor
|
||||
|
||||
return binVector(theLocBin) +
|
||||
( binVector(theLocBin+1)-binVector(theLocBin) ) * intplFactor;
|
||||
return binVector[theLocBin] +
|
||||
( binVector[theLocBin+1]-binVector[theLocBin] ) * intplFactor;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsTable.cc,v 1.5 2001/04/03 07:26:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation
|
||||
//
|
||||
// G4PhysicsTable
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4PhysicsVector.hh"
|
||||
#include "G4PhysicsTable.hh"
|
||||
#include "g4std/iostream"
|
||||
#include "g4std/fstream"
|
||||
#include "g4std/iomanip"
|
||||
|
||||
G4PhysicsTable::G4PhysicsTable()
|
||||
: G4PhysCollection()
|
||||
{
|
||||
}
|
||||
|
||||
G4PhysicsTable::G4PhysicsTable(size_t capacity)
|
||||
: G4PhysCollection()
|
||||
{
|
||||
reserve(capacity);
|
||||
}
|
||||
|
||||
G4PhysicsTable::G4PhysicsTable(const G4PhysicsTable& right)
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
G4PhysicsTable& G4PhysicsTable::operator=(const G4PhysicsTable& right)
|
||||
{
|
||||
if (this != &right)
|
||||
{
|
||||
G4PhysCollection::const_iterator itr;
|
||||
for (itr=right.begin(); itr!=right.end(); ++itr)
|
||||
{
|
||||
G4PhysCollection::push_back(*itr);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4PhysicsTable::~G4PhysicsTable()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
G4bool G4PhysicsTable::StorePhysicsTable(const G4String& fileName,
|
||||
G4bool ascii)
|
||||
{
|
||||
G4std::ofstream fOut;
|
||||
|
||||
// open output file //
|
||||
#ifdef G4USE_STD_NAMESPACE
|
||||
if (!ascii)
|
||||
fOut.open(fileName, G4std::ios::out|G4std::ios::binary);
|
||||
else
|
||||
#endif
|
||||
fOut.open(fileName, G4std::ios::out);
|
||||
|
||||
// check if the file has been opened successfully
|
||||
if (!fOut) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cerr << "G4PhysicsTable::::StorePhysicsTable ";
|
||||
G4cerr << " Can not open file " << fileName << G4endl;
|
||||
#endif
|
||||
fOut.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Number of elements
|
||||
size_t tableSize = size();
|
||||
if (!ascii){
|
||||
fOut.write( (char*)(&tableSize), sizeof tableSize);
|
||||
} else {
|
||||
fOut << tableSize << G4endl;
|
||||
}
|
||||
|
||||
// Physics Vector
|
||||
G4PhysicsTableIterator itr;
|
||||
for (itr=begin(); itr!=end(); ++itr) {
|
||||
G4int vType = (*itr)->GetType();
|
||||
if (!ascii){
|
||||
fOut.write( (char*)(&vType), sizeof vType);
|
||||
} else {
|
||||
fOut << vType << G4endl;
|
||||
}
|
||||
(*itr)->Store(fOut,ascii);
|
||||
}
|
||||
fOut.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
|
||||
G4bool ascii)
|
||||
{
|
||||
G4std::ifstream fIn;
|
||||
// open input file //
|
||||
#ifdef G4USE_STD_NAMESPACE
|
||||
if (ascii)
|
||||
fIn.open(fileName,G4std::ios::in|G4std::ios::binary);
|
||||
else
|
||||
#endif
|
||||
fIn.open(fileName,G4std::ios::in);
|
||||
|
||||
// check if the file has been opened successfully
|
||||
if (!fIn) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
|
||||
G4cerr << " Can not open file " << fileName << G4endl;
|
||||
#endif
|
||||
fIn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear
|
||||
clearAndDestroy();
|
||||
|
||||
// Number of elements
|
||||
size_t tableSize;
|
||||
if (!ascii){
|
||||
fIn.read((char*)(&tableSize), sizeof tableSize);
|
||||
} else {
|
||||
fIn >> tableSize;
|
||||
}
|
||||
reserve(tableSize);
|
||||
|
||||
// Physics Vector
|
||||
for (size_t idx=0; idx<tableSize; ++idx) {
|
||||
G4int vType;
|
||||
if (!ascii){
|
||||
fIn.read( (char*)(&vType), sizeof vType);
|
||||
} else {
|
||||
fIn >> vType;
|
||||
}
|
||||
G4PhysicsVector* pVec = CreatePhysicsVector(vType);
|
||||
if (pVec==0) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
|
||||
G4cerr << " illegal Physics Vector type " << vType << " in ";
|
||||
G4cerr << fileName << G4endl;
|
||||
#endif
|
||||
fIn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! (pVec->Retrieve(fIn,ascii)) ){
|
||||
#ifdef G4VERBOSE
|
||||
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
|
||||
G4cerr << " error in retreiving " << idx << "-th Physics Vector from file ";
|
||||
G4cerr << fileName << G4endl;
|
||||
#endif
|
||||
fIn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// add a PhysicsVector to this PhysicsTable
|
||||
push_back(pVec);
|
||||
}
|
||||
fIn.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
G4std::ostream& operator<<(G4std::ostream& out,
|
||||
G4PhysicsTable& right)
|
||||
{
|
||||
// Printout Physics Vector
|
||||
G4PhysicsTableIterator itr;
|
||||
size_t i=0;
|
||||
for (itr=right.begin(); itr!=right.end(); ++itr) {
|
||||
out << G4std::setw(8) << i << "-th Vector ";
|
||||
out << ": Type " << G4int((*itr)->GetType()) << G4endl;
|
||||
out << *(*itr);
|
||||
i +=1;
|
||||
}
|
||||
out << G4endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
#include "G4PhysicsVectorType.hh"
|
||||
#include "G4LPhysicsFreeVector.hh"
|
||||
#include "G4PhysicsLogVector.hh"
|
||||
#include "G4PhysicsFreeVector.hh"
|
||||
#include "G4PhysicsOrderedFreeVector.hh"
|
||||
#include "G4PhysicsLinearVector.hh"
|
||||
#include "G4PhysicsLnVector.hh"
|
||||
|
||||
G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
|
||||
{
|
||||
G4PhysicsVector* pVector=0;
|
||||
switch (type) {
|
||||
|
||||
case T_G4PhysicsLinearVector:
|
||||
pVector = new G4PhysicsLinearVector();
|
||||
break;
|
||||
|
||||
case T_G4PhysicsLogVector:
|
||||
pVector = new G4PhysicsLogVector();
|
||||
break;
|
||||
|
||||
case T_G4PhysicsLnVector:
|
||||
pVector = new G4PhysicsLnVector();
|
||||
break;
|
||||
|
||||
case T_G4PhysicsFreeVector:
|
||||
pVector = new G4PhysicsFreeVector();
|
||||
break;
|
||||
|
||||
case T_G4PhysicsOrderedFreeVector:
|
||||
pVector = new G4PhysicsOrderedFreeVector();
|
||||
break;
|
||||
|
||||
case T_G4LPhysicsFreeVector:
|
||||
pVector = new G4LPhysicsFreeVector();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return pVector;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsVector.cc,v 1.5 2000/11/20 17:26:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4PhysicsVector.cc,v 1.11 2001/03/09 13:36:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
@@ -14,35 +14,45 @@
|
||||
//
|
||||
// G4PhysicsVector.cc
|
||||
//
|
||||
// History: first implementation, based on object model of
|
||||
// History:
|
||||
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
|
||||
// 03 Mar. 1996, K.Amako : Implemented the 1st version
|
||||
// 01 Jul. 1996, K.Amako : Hidden bin from the user introduced
|
||||
// 12 Nov. 1998, K.Amako : A bug in GetVectorLength() fixed
|
||||
//
|
||||
// 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
|
||||
// 18 Jan. 2001, H.Kurashige : removed ptrNextTable
|
||||
// 09 Mar. 2001, H.Kurashige : added G4PhysicsVector type
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "G4PhysicsVector.hh"
|
||||
#include "g4std/iomanip"
|
||||
|
||||
G4PhysicsVector::G4PhysicsVector()
|
||||
: edgeMin(0.), edgeMax(0.), numberOfBin(0),
|
||||
lastEnergy(0.), lastValue(0.), lastBin(0),
|
||||
ptrNextTable(0) {}
|
||||
lastEnergy(0.), lastValue(0.), lastBin(0)
|
||||
{
|
||||
type = T_G4PhysicsVector;
|
||||
}
|
||||
|
||||
G4PhysicsVector::~G4PhysicsVector() {}
|
||||
G4PhysicsVector::~G4PhysicsVector()
|
||||
{
|
||||
dataVector.clear();
|
||||
binVector.clear();
|
||||
type = T_G4PhysicsVector;
|
||||
}
|
||||
|
||||
G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right)
|
||||
: edgeMin(right.edgeMin), edgeMax(right.edgeMax),
|
||||
numberOfBin(right.numberOfBin), lastEnergy(right.lastEnergy),
|
||||
lastValue(right.lastValue), lastBin(right.lastBin),
|
||||
dataVector(right.dataVector), binVector(right.binVector),
|
||||
ptrNextTable(right.ptrNextTable), comment(right.comment) {}
|
||||
{
|
||||
*this=right;
|
||||
}
|
||||
|
||||
G4PhysicsVector&
|
||||
G4PhysicsVector::operator=(const G4PhysicsVector& right)
|
||||
G4PhysicsVector::operator=(const G4PhysicsVector& right)
|
||||
{
|
||||
if (&right==this) return *this;
|
||||
if (type != right.type) return *this;
|
||||
|
||||
type = right.type;
|
||||
edgeMin = right.edgeMin;
|
||||
edgeMax = right.edgeMax;
|
||||
numberOfBin = right.numberOfBin;
|
||||
@@ -51,9 +61,7 @@ G4PhysicsVector::operator=(const G4PhysicsVector& right)
|
||||
lastBin = right.lastBin;
|
||||
dataVector = right.dataVector;
|
||||
binVector = right.binVector;
|
||||
ptrNextTable = right.ptrNextTable;
|
||||
comment = right.comment;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -67,66 +75,111 @@ G4int G4PhysicsVector::operator!=(const G4PhysicsVector &right) const
|
||||
return (this != &right);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
G4double G4PhysicsVector::GetLowEdgeEnergy(size_t binNumber) const
|
||||
{
|
||||
return binVector(binNumber);
|
||||
return binVector[binNumber];
|
||||
}
|
||||
|
||||
size_t G4PhysicsVector::GetVectorLength() const
|
||||
G4bool G4PhysicsVector::Store(G4std::ofstream& fOut, G4bool ascii)
|
||||
{
|
||||
return numberOfBin;
|
||||
// Ascii mode
|
||||
if (ascii) {
|
||||
fOut << *this;
|
||||
return true;
|
||||
}
|
||||
// Binary Mode
|
||||
|
||||
// binning
|
||||
fOut.write((char*)(&edgeMin), sizeof edgeMin);
|
||||
fOut.write((char*)(&edgeMax), sizeof edgeMax);
|
||||
fOut.write((char*)(&numberOfBin), sizeof numberOfBin);
|
||||
|
||||
// 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++) {
|
||||
value[2*i] = binVector[i];
|
||||
value[2*i+1]= dataVector[i];
|
||||
}
|
||||
fOut.write((char*)(value), 2*size*(sizeof (G4double)));
|
||||
delete [] value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
G4bool G4PhysicsVector::IsFilledVectorExist() const
|
||||
G4bool G4PhysicsVector::Retrieve(G4std::ifstream& fIn, G4bool ascii)
|
||||
{
|
||||
G4bool status=false;
|
||||
// clear properties;
|
||||
lastEnergy=0.;
|
||||
lastValue =0.;
|
||||
lastBin =0;
|
||||
dataVector.clear();
|
||||
binVector.clear();
|
||||
comment = "";
|
||||
|
||||
if(numberOfBin > 0) status=true;
|
||||
return status;
|
||||
// retrieve in ascii mode
|
||||
if (ascii) {
|
||||
// binning
|
||||
fIn >> edgeMin >> edgeMax >> numberOfBin;
|
||||
if (fIn.fail()) return false;
|
||||
// contents
|
||||
size_t size;
|
||||
fIn >> size;
|
||||
if (fIn.fail()) return false;
|
||||
|
||||
binVector.reserve(size);
|
||||
dataVector.reserve(size);
|
||||
for(size_t i = 0; i < size ; i++) {
|
||||
G4double vBin, vData;
|
||||
fIn >> vBin >> vData;
|
||||
if (fIn.fail()) return false;
|
||||
binVector.push_back(vBin);
|
||||
dataVector.push_back(vData);
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// retrieve in binary mode
|
||||
// binning
|
||||
fIn.read((char*)(&edgeMin), sizeof edgeMin);
|
||||
fIn.read((char*)(&edgeMax), sizeof edgeMax);
|
||||
fIn.read((char*)(&numberOfBin), sizeof numberOfBin );
|
||||
|
||||
// contents
|
||||
size_t size;
|
||||
fIn.read((char*)(&size), sizeof size);
|
||||
|
||||
G4double* value = new G4double[2*size];
|
||||
fIn.read((char*)(value), 2*size*(sizeof(G4double)) );
|
||||
if (fIn.gcount() != 2*size*(sizeof(G4double)) ){
|
||||
delete [] value;
|
||||
return false;
|
||||
}
|
||||
|
||||
binVector.reserve(size);
|
||||
dataVector.reserve(size);
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
binVector.push_back(value[2*i]);
|
||||
dataVector.push_back(value[2*i+1]);
|
||||
}
|
||||
delete [] value;
|
||||
return true;
|
||||
}
|
||||
|
||||
void G4PhysicsVector::LinkPhysicsTable(G4RWTPtrOrderedVector<G4PhysicsVector>& theTable)
|
||||
|
||||
G4std::ostream& operator<<(G4std::ostream& out, const G4PhysicsVector& pv)
|
||||
{
|
||||
ptrNextTable = &theTable;
|
||||
}
|
||||
// binning
|
||||
out << G4std::setprecision(12) << pv.edgeMin;
|
||||
out <<" " << pv.edgeMax <<" " << pv.numberOfBin << G4endl;
|
||||
|
||||
G4bool G4PhysicsVector::IsLinkedTableExist() const
|
||||
{
|
||||
G4bool status=false;
|
||||
// contents
|
||||
size_t i;
|
||||
out << pv.dataVector.size() << G4endl;
|
||||
for(i = 0; i < pv.dataVector.size(); i++) {
|
||||
out << G4std::setprecision(12) << pv.binVector[i] <<" " << pv.dataVector[i] << G4endl;
|
||||
}
|
||||
|
||||
if(ptrNextTable != 0) status=true;
|
||||
return status;
|
||||
return out;
|
||||
}
|
||||
|
||||
void G4PhysicsVector::PutComment(const G4String& theComment)
|
||||
{
|
||||
comment = theComment;
|
||||
}
|
||||
|
||||
G4String G4PhysicsVector::GetComment() const
|
||||
{
|
||||
return comment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4StateManager.cc,v 1.2 2000/11/20 17:26:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// $Id: G4StateManager.cc,v 1.3 2001/03/06 15:56:52 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
@@ -24,12 +24,31 @@
|
||||
G4StateManager* G4StateManager::theStateManager = 0;
|
||||
|
||||
G4StateManager::G4StateManager()
|
||||
:theCurrentState(PreInit),thePreviousState(PreInit)
|
||||
{ theBottomDependent = 0; }
|
||||
: theCurrentState(PreInit),
|
||||
thePreviousState(PreInit),
|
||||
theBottomDependent(0)
|
||||
{
|
||||
}
|
||||
|
||||
G4StateManager::~G4StateManager()
|
||||
{
|
||||
theDependentsList.clearAndDestroy();
|
||||
G4VStateDependent* state=0;
|
||||
|
||||
while (theDependentsList.size()>0)
|
||||
{
|
||||
state = theDependentsList.back();
|
||||
theDependentsList.pop_back();
|
||||
for (G4std::vector<G4VStateDependent*>::iterator
|
||||
i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
|
||||
{
|
||||
if (*i==state)
|
||||
{
|
||||
theDependentsList.erase(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if ( state ) delete state;
|
||||
}
|
||||
}
|
||||
|
||||
G4StateManager::G4StateManager(const G4StateManager &right)
|
||||
@@ -40,7 +59,8 @@ G4StateManager::G4StateManager(const G4StateManager &right)
|
||||
{
|
||||
}
|
||||
|
||||
G4StateManager& G4StateManager::operator=(const G4StateManager &right)
|
||||
G4StateManager&
|
||||
G4StateManager::operator=(const G4StateManager &right)
|
||||
{
|
||||
if (&right == this) return *this;
|
||||
|
||||
@@ -52,69 +72,93 @@ G4StateManager& G4StateManager::operator=(const G4StateManager &right)
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4int G4StateManager::operator==(const G4StateManager &right) const
|
||||
G4int
|
||||
G4StateManager::operator==(const G4StateManager &right) const
|
||||
{
|
||||
return (this == &right);
|
||||
}
|
||||
|
||||
G4int G4StateManager::operator!=(const G4StateManager &right) const
|
||||
G4int
|
||||
G4StateManager::operator!=(const G4StateManager &right) const
|
||||
{
|
||||
return (this != &right);
|
||||
}
|
||||
|
||||
|
||||
G4StateManager* G4StateManager::GetStateManager()
|
||||
G4StateManager*
|
||||
G4StateManager::GetStateManager()
|
||||
{
|
||||
if (!theStateManager)
|
||||
{
|
||||
theStateManager = new G4StateManager;
|
||||
}
|
||||
{
|
||||
theStateManager = new G4StateManager;
|
||||
}
|
||||
return theStateManager;
|
||||
}
|
||||
|
||||
G4bool G4StateManager::RegisterDependent(G4VStateDependent* aDependent,G4bool bottom)
|
||||
G4bool
|
||||
G4StateManager::RegisterDependent(G4VStateDependent* aDependent, G4bool bottom)
|
||||
{
|
||||
G4bool ack=true;
|
||||
if(!bottom)
|
||||
{ theDependentsList.insert(aDependent); }
|
||||
else
|
||||
{
|
||||
if(theBottomDependent)
|
||||
{ theDependentsList.insert(theBottomDependent); }
|
||||
theBottomDependent = aDependent;
|
||||
}
|
||||
return ack;
|
||||
G4bool ack=true;
|
||||
if(!bottom)
|
||||
{
|
||||
theDependentsList.push_back(aDependent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(theBottomDependent)
|
||||
{
|
||||
theDependentsList.push_back(theBottomDependent);
|
||||
}
|
||||
theBottomDependent = aDependent;
|
||||
}
|
||||
return ack;
|
||||
}
|
||||
|
||||
G4bool G4StateManager::DeregisterDependent(G4VStateDependent* aDependent)
|
||||
G4bool
|
||||
G4StateManager::DeregisterDependent(G4VStateDependent* aDependent)
|
||||
{
|
||||
G4VStateDependent* aD = theDependentsList.remove(aDependent);
|
||||
return (aD != NULL);
|
||||
G4VStateDependent* tmp = 0;
|
||||
G4std::vector<G4VStateDependent*>::iterator i;
|
||||
for (i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
|
||||
{
|
||||
if (**i==*aDependent)
|
||||
{
|
||||
tmp = *i;
|
||||
theDependentsList.erase(i);
|
||||
}
|
||||
}
|
||||
return (tmp != 0);
|
||||
}
|
||||
|
||||
G4ApplicationState G4StateManager::GetCurrentState()
|
||||
G4ApplicationState
|
||||
G4StateManager::GetCurrentState() const
|
||||
{
|
||||
return theCurrentState;
|
||||
}
|
||||
|
||||
G4ApplicationState G4StateManager::GetPreviousState()
|
||||
G4ApplicationState
|
||||
G4StateManager::GetPreviousState() const
|
||||
{
|
||||
return thePreviousState;
|
||||
}
|
||||
|
||||
G4bool G4StateManager::SetNewState(G4ApplicationState requestedState)
|
||||
G4bool
|
||||
G4StateManager::SetNewState(G4ApplicationState requestedState)
|
||||
{
|
||||
size_t i=0;
|
||||
G4bool ack = true;
|
||||
G4ApplicationState savedState = thePreviousState;
|
||||
thePreviousState = theCurrentState;
|
||||
theCurrentState = requestedState;
|
||||
while ((ack) && (i<theDependentsList.entries())) {
|
||||
ack = theDependentsList(i)->Notify(requestedState);
|
||||
while ((ack) && (i<theDependentsList.size()))
|
||||
{
|
||||
ack = theDependentsList[i]->Notify(requestedState);
|
||||
i++;
|
||||
}
|
||||
if(theBottomDependent)
|
||||
{ ack = theBottomDependent->Notify(requestedState); }
|
||||
{
|
||||
ack = theBottomDependent->Notify(requestedState);
|
||||
}
|
||||
|
||||
if(!ack)
|
||||
{
|
||||
@@ -124,12 +168,24 @@ G4bool G4StateManager::SetNewState(G4ApplicationState requestedState)
|
||||
return ack;
|
||||
}
|
||||
|
||||
G4VStateDependent* G4StateManager::RemoveDependent(const G4VStateDependent* aDependent)
|
||||
G4VStateDependent*
|
||||
G4StateManager::RemoveDependent(const G4VStateDependent* aDependent)
|
||||
{
|
||||
return theDependentsList.remove(aDependent);
|
||||
G4VStateDependent* tmp = 0;
|
||||
G4std::vector<G4VStateDependent*>::iterator i;
|
||||
for (i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
|
||||
{
|
||||
if (**i==*aDependent)
|
||||
{
|
||||
tmp = *i;
|
||||
theDependentsList.erase(i);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
G4String G4StateManager::GetStateString(G4ApplicationState aState)
|
||||
G4String
|
||||
G4StateManager::GetStateString(G4ApplicationState aState) const
|
||||
{
|
||||
G4String stateName;
|
||||
switch(aState)
|
||||
@@ -169,4 +225,3 @@ G4String G4StateManager::GetStateString(G4ApplicationState aState)
|
||||
//{
|
||||
// G4UImanager::GetUIpointer()->PauseSession(msg);
|
||||
//}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Timer.cc,v 1.8 2000/06/26 16:27:37 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -5,18 +5,16 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UnitsTable.cc,v 1.11 2000/11/20 17:26:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
//
|
||||
// $Id: G4UnitsTable.cc,v 1.14 2001/04/02 14:29:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// ------------ class G4UnitsTable ------------
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//
|
||||
// 17-05-98: first version, M.Maire
|
||||
// 05-08-98: angstrom,microbarn,picobarn,petaelectronvolt
|
||||
// 13-10-98: Units and symbols printed in fixed length
|
||||
// 05-08-98: angstrom,microbarn,picobarn,petaelectronvolt, M.Maire
|
||||
// 13-10-98: units and symbols printed in fixed length, M.Maire
|
||||
// 01-03-01: parsec, M.Maire
|
||||
// 06-03-01: migration to STL vectors, G.Cosmo
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -32,18 +30,18 @@ G4UnitsTable G4UnitDefinition::theUnitsTable;
|
||||
|
||||
G4UnitDefinition::G4UnitDefinition(G4String name, G4String symbol,
|
||||
G4String category, G4double value)
|
||||
:Name(name),SymbolName(symbol),Value(value)
|
||||
: Name(name),SymbolName(symbol),Value(value)
|
||||
{
|
||||
//
|
||||
//does the Category objet already exist ?
|
||||
size_t nbCat = theUnitsTable.entries();
|
||||
size_t nbCat = theUnitsTable.size();
|
||||
size_t i = 0;
|
||||
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
|
||||
if (i == nbCat) theUnitsTable.insert( new G4UnitsCategory(category));
|
||||
if (i == nbCat) theUnitsTable.push_back( new G4UnitsCategory(category));
|
||||
CategoryIndex = i;
|
||||
//
|
||||
//insert this Unit in the Unitstable
|
||||
(theUnitsTable[CategoryIndex]->GetUnitsList()).insert(this);
|
||||
(theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(this);
|
||||
|
||||
//update string max length for name and symbol
|
||||
theUnitsTable[i]->UpdateNameMxLen((G4int)name.length());
|
||||
@@ -95,11 +93,11 @@ G4int G4UnitDefinition::operator!=(const G4UnitDefinition &right) const
|
||||
|
||||
G4double G4UnitDefinition::GetValueOf(G4String string)
|
||||
{
|
||||
if(theUnitsTable.entries()==0) BuildUnitsTable();
|
||||
if(theUnitsTable.size()==0) BuildUnitsTable();
|
||||
G4String name,symbol;
|
||||
for (size_t i=0;i<theUnitsTable.entries();i++)
|
||||
for (size_t i=0;i<theUnitsTable.size();i++)
|
||||
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
|
||||
for (size_t j=0;j<units.entries();j++)
|
||||
for (size_t j=0;j<units.size();j++)
|
||||
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
|
||||
if(string==name||string==symbol)
|
||||
return units[j]->GetValue();
|
||||
@@ -115,11 +113,11 @@ G4double G4UnitDefinition::GetValueOf(G4String string)
|
||||
|
||||
G4String G4UnitDefinition::GetCategory(G4String string)
|
||||
{
|
||||
if(theUnitsTable.entries()==0) BuildUnitsTable();
|
||||
if(theUnitsTable.size()==0) BuildUnitsTable();
|
||||
G4String name,symbol;
|
||||
for (size_t i=0;i<theUnitsTable.entries();i++)
|
||||
for (size_t i=0;i<theUnitsTable.size();i++)
|
||||
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
|
||||
for (size_t j=0;j<units.entries();j++)
|
||||
for (size_t j=0;j<units.size();j++)
|
||||
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
|
||||
if(string==name||string==symbol)
|
||||
return theUnitsTable[i]->GetName();
|
||||
@@ -147,6 +145,7 @@ void G4UnitDefinition::PrintDefinition()
|
||||
void G4UnitDefinition::BuildUnitsTable()
|
||||
{
|
||||
//Length
|
||||
new G4UnitDefinition( "parsec","pc" ,"Length",parsec);
|
||||
new G4UnitDefinition( "kilometer","km" ,"Length",kilometer);
|
||||
new G4UnitDefinition( "meter","m" ,"Length",meter);
|
||||
new G4UnitDefinition("centimeter","cm" ,"Length",centimeter);
|
||||
@@ -263,7 +262,7 @@ void G4UnitDefinition::BuildUnitsTable()
|
||||
void G4UnitDefinition::PrintUnitsTable()
|
||||
{
|
||||
G4cout << "\n ----- The Table of Units ----- \n";
|
||||
for(size_t i=0;i<theUnitsTable.entries();i++)
|
||||
for(size_t i=0;i<theUnitsTable.size();i++)
|
||||
theUnitsTable[i]->PrintCategory();
|
||||
}
|
||||
|
||||
@@ -320,7 +319,7 @@ G4int G4UnitsCategory::operator!=(const G4UnitsCategory &right) const
|
||||
void G4UnitsCategory::PrintCategory()
|
||||
{
|
||||
G4cout << "\n category: " << Name << G4endl;
|
||||
for(size_t i=0;i<UnitsList.entries();i++)
|
||||
for(size_t i=0;i<UnitsList.size();i++)
|
||||
UnitsList[i]->PrintDefinition();
|
||||
}
|
||||
|
||||
@@ -330,14 +329,14 @@ G4BestUnit::G4BestUnit(G4double value,G4String category)
|
||||
{
|
||||
// find the category
|
||||
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
|
||||
size_t nbCat = theUnitsTable.entries();
|
||||
size_t nbCat = theUnitsTable.size();
|
||||
size_t i = 0;
|
||||
while
|
||||
((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
|
||||
if (i == nbCat)
|
||||
{ G4cout << " G4BestUnit: the category " << category
|
||||
<< " does not exist; --> G4Exception" << G4endl;
|
||||
G4Exception(" ");
|
||||
<< " does not exist !!" << G4endl;
|
||||
G4Exception("Missing unit category !");
|
||||
}
|
||||
//
|
||||
IndexOfCategory = i;
|
||||
@@ -351,7 +350,7 @@ G4BestUnit::G4BestUnit(const G4ThreeVector& value,G4String category)
|
||||
{
|
||||
// find the category
|
||||
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
|
||||
size_t nbCat = theUnitsTable.entries();
|
||||
size_t nbCat = theUnitsTable.size();
|
||||
size_t i = 0;
|
||||
while
|
||||
((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
|
||||
@@ -389,7 +388,7 @@ G4std::ostream& operator<<(G4std::ostream& flux, G4BestUnit a)
|
||||
G4double value = G4std::max(G4std::max(fabs(a.Value[0]),fabs(a.Value[1])),
|
||||
fabs(a.Value[2]));
|
||||
|
||||
for (size_t k=0; k<List.entries(); k++)
|
||||
for (size_t k=0; k<List.size(); k++)
|
||||
{
|
||||
G4double unit = List[k]->GetValue();
|
||||
if (value==DBL_MAX) {if(unit>umax) {umax=unit; ksup=k;}}
|
||||
@@ -405,10 +404,17 @@ G4std::ostream& operator<<(G4std::ostream& flux, G4BestUnit a)
|
||||
|
||||
for (G4int j=0; j<a.nbOfVals; j++)
|
||||
{flux << a.Value[j]/(List[index]->GetValue()) << " ";}
|
||||
G4long oldform = G4cout.setf(G4std::ios::left,G4std::ios::adjustfield);
|
||||
|
||||
#ifdef G4USE_STD_NAMESPACE
|
||||
std::ios::fmtflags oldform = G4cout.flags();
|
||||
#else
|
||||
G4long oldform = G4cout.flags();
|
||||
#endif
|
||||
|
||||
G4cout.setf(G4std::ios::left,G4std::ios::adjustfield);
|
||||
flux << G4std::setw(len) << List[index]->GetSymbol();
|
||||
G4cout.setf(oldform,G4std::ios::adjustfield);
|
||||
|
||||
G4cout.flags(oldform);
|
||||
|
||||
return flux;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VStateDependent.cc,v 1.2 2000/11/20 17:26:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4ios.cc,v 1.4 1999/11/23 15:00:06 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-03-00 $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user