Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Exception.cc,v 2.1 1998/07/13 16:55:54 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ----------------------------------------------------------------------
// G4Exception
//
// Global error function prints string to G4cerr, and aborts
// program
//
// History:
// 30.06.95 P.Kent
#include "G4ios.hh"
#include <stdlib.h>
void G4Exception(const char* s)
{
if (s)
{
G4cerr << s << endl;
}
G4cerr << endl << "*** G4Exception: Aborting execution ***" << endl;
exit(1);
}
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 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: G4LPhysicsFreeVector.cc,v 2.1 1998/07/12 02:59:05 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------------
// Class G4LPhysicsFreeVector
// Derived from base class G4PhysicsVector
// This is a free vector for Low Energy Physics cross section data
//
// F.W. Jones, TRIUMF, 04-JUN-96
//
// 27-MAR-97 FWJ: first version for Alpha release
//
#include "G4LPhysicsFreeVector.hh"
#include <stdio.h>
G4LPhysicsFreeVector::G4LPhysicsFreeVector()
{
ptrNextTable = 0;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
verboseLevel = 0;
}
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin, G4double binmin,
G4double binmax)
{
edgeMin = binmin;
edgeMax = binmax;
numberOfBin = nbin;
lastEnergy = 0.;
lastValue = 0.;
lastBin = 0;
binVector.resize(nbin);
dataVector.resize(nbin);
ptrNextTable = 0;
verboseLevel = 0;
}
G4LPhysicsFreeVector::~G4LPhysicsFreeVector()
{
}
void G4LPhysicsFreeVector::DumpValues()
{
for (G4int 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);
}
}
@@ -0,0 +1,132 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PhysicsFreeVector.cc,v 2.0 1998/07/02 17:33:22 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//--------------------------------------------------------------------
// GEANT 4 class implementation file
//
// G4PhysicsFreeVector.cc
//
// History:
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
// 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.
//
//--------------------------------------------------------------------
#include "G4PhysicsFreeVector.hh"
G4PhysicsFreeVector::G4PhysicsFreeVector()
{
ptrNextTable = 0;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
}
G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
{
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);
ptrNextTable = 0;
edgeMin = 0.;
edgeMax = 0.;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
const G4DataVector& theDataVector)
{
numberOfBin = theBinVector.entries();
// 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;
for (int i=0; i<numberOfBin; i++) {
binVector(i) = theBinVector(i);
dataVector(i) = 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;
// 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);
edgeMin = binVector(0);
edgeMax = binVector(numberOfBin-1);
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsFreeVector::~G4PhysicsFreeVector(){}
void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue,
G4double theDataValue )
{
binVector(theBinNumber) = theBinValue;
dataVector(theBinNumber) = theDataValue;
if( theBinNumber == 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;
// 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;
}
if( theBinNumber == 0 ) {
edgeMin = binVector(0);
}
}
@@ -0,0 +1,89 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PhysicsLinearVector.cc,v 2.0 1998/07/02 17:33:24 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//--------------------------------------------------------------------
// GEANT 4 class implementation file
//
// G4PhysicsLinearVector.cc
//
// History: first implementation, based on object model of
// 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.
//
//--------------------------------------------------------------------
#include "G4PhysicsLinearVector.hh"
G4PhysicsLinearVector::G4PhysicsLinearVector()
{
ptrNextTable = 0;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
}
G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
{
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.resize(theNbin+1);
binVector.resize(theNbin+1);
ptrNextTable = 0;
numberOfBin = theNbin;
dBin = 0.;
baseBin = 0.;
edgeMin = 0.;
edgeMax = 0.;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
G4double theEmax, size_t theNbin)
{
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.resize(theNbin+1);
binVector.resize(theNbin+1);
ptrNextTable = 0;
numberOfBin = theNbin;
dBin = (theEmax-theEmin) / numberOfBin;
baseBin = theEmin/dBin;
for (G4int i=0; i<numberOfBin+1; i++) {
binVector(i) = theEmin + i*dBin;
}
edgeMin = binVector(0);
edgeMax = binVector(numberOfBin-1);
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsLinearVector::~G4PhysicsLinearVector(){}
@@ -0,0 +1,92 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PhysicsLogVector.cc,v 2.0 1998/07/02 17:33:26 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
// G4PhysicsLogVector.cc
//
// History: first implementation, based on object model of
// 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.
//
// --------------------------------------------------------------
#include "G4PhysicsLogVector.hh"
G4PhysicsLogVector::G4PhysicsLogVector()
{
ptrNextTable = 0;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
}
G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
{
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.resize(theNbin+1);
binVector.resize(theNbin+1);
ptrNextTable = 0;
numberOfBin = theNbin;
dBin = 0.;
baseBin = 0.;
edgeMin = 0.;
edgeMax = 0.;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
G4double theEmax, size_t theNbin)
{
// Add extra one bin (hidden to user) to handle correctly when
// Energy=theEmax in getValue.
dataVector.resize(theNbin+1);
binVector.resize(theNbin+1);
ptrNextTable = 0;
numberOfBin = theNbin;
dBin = log10(theEmax/theEmin) / numberOfBin;
baseBin = log10(theEmin)/dBin;
for (G4int i=0; i<numberOfBin+1; i++) {
binVector(i) = pow(10., log10(theEmin)+i*dBin);
}
edgeMin = binVector(0);
edgeMax = binVector(numberOfBin-1);
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
G4PhysicsLogVector::~G4PhysicsLogVector(){}
@@ -0,0 +1,143 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PhysicsOrderedFreeVector.cc,v 2.1 1998/11/11 23:19:11 gum Exp $
// GEANT4 tag $Name: geant4-00 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Implementation
////////////////////////////////////////////////////////////////////////
//
// File: G4PhysicsOrderedFreeVector.cc
// Version: 2.0
// Created: 1996-08-13
// Author: Juliet Armstrong
// Updated: 1997-03-25 by Peter Gumplinger
// > cosmetics (only)
// 1998-11-11 by Peter Gumplinger
// > initialize all data members of the base class in
// derived class constructors
// mail: gum@triumf.ca
//
//
////////////////////////////////////////////////////////////////////////
#include "G4PhysicsOrderedFreeVector.hh"
/////////////////////////
// Class Implementation
/////////////////////////
/////////////////
// Constructors
/////////////////
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
G4double *Values,
size_t VectorLength)
{
ptrNextTable = 0;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
numberOfBin = VectorLength;
for (G4int i = 0 ; i < VectorLength ; i++)
{
binVector.insert(Energies[i]);
dataVector.insert(Values[i]);
}
edgeMin = binVector.first();
edgeMax = binVector.last();
}
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
{
ptrNextTable = 0;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
}
////////////////
// Destructors
////////////////
G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector() {}
////////////
// Methods
////////////
void
G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
{
binVector.insert(energy);
dataVector.insert(value);
numberOfBin++;
edgeMin = binVector.first();
edgeMax = binVector.last();
}
G4double
G4PhysicsOrderedFreeVector::GetLowEdgeEnergy(size_t binNumber) const
{
return binVector[binNumber];
}
G4double
G4PhysicsOrderedFreeVector::GetEnergy(G4double aValue)
{
if (aValue <= GetMinValue()) {
return GetMinLowEdgeEnergy();
} else if (aValue >= GetMaxValue()) {
return GetMaxLowEdgeEnergy();
} else {
size_t closestBin = FindValueBinLocation(aValue);
G4double theEnergy = LinearInterpolationOfEnergy(aValue, closestBin);
return theEnergy;
}
}
size_t
G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
while (n1 != n3 - 1) {
if (aValue > dataVector(n2))
n1 = n2;
else
n3 = n2;
n2 = n1 + (n3 - n1 + 1)/2;
}
return (size_t)n1;
}
G4double
G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(G4double aValue,
size_t theLocBin)
{
G4double intplFactor = (aValue-dataVector(theLocBin))
/ (dataVector(theLocBin+1)-dataVector(theLocBin)); // Interpolation factor
return binVector(theLocBin) +
( binVector(theLocBin+1)-binVector(theLocBin) ) * intplFactor;
}
@@ -0,0 +1,100 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PhysicsVector.cc,v 2.1 1998/11/12 04:30:42 amako Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
// G4PhysicsVector.cc
//
// History: first implementation, based on object model of
// 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
//
// --------------------------------------------------------------
#include "G4PhysicsVector.hh"
G4int G4PhysicsVector::operator==(const G4PhysicsVector &right) const
{
return (this == (G4PhysicsVector *) &right);
}
G4int G4PhysicsVector::operator!=(const G4PhysicsVector &right) const
{
return (this != (G4PhysicsVector *) &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);
}
size_t G4PhysicsVector::GetVectorLength() const
{
return numberOfBin;
}
G4bool G4PhysicsVector::IsFilledVectorExist() const
{
G4bool status=false;
if(numberOfBin > 0) status=true;
return status;
}
void G4PhysicsVector::LinkPhysicsTable(RWTPtrOrderedVector<G4PhysicsVector>& theTable)
{
ptrNextTable = &theTable;
}
G4bool G4PhysicsVector::IsLinkedTableExist() const
{
G4bool status=false;
if(ptrNextTable != 0) status=true;
return status;
}
void G4PhysicsVector::PutComment(const G4String& theComment)
{
comment = theComment;
}
G4String G4PhysicsVector::GetComment() const
{
return comment;
}
+103
View File
@@ -0,0 +1,103 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Timer.cc,v 2.3 1998/07/17 08:56:21 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ----------------------------------------------------------------------
// class G4Timer
//
// Implementation
// 29.04.97 G.Cosmo Added timings for Windows/NT
#include "G4Timer.hh"
#include "G4ios.hh"
#ifdef WIN32
# include <sys/types.h>
# include <windows.h>
// extract milliseconds time unit
int sysconf(int a){
if( a == _SC_CLK_TCK ) return 1000;
else return 0;
}
static clock_t filetime2msec( FILETIME* t ){
return (clock_t)((((float)t->dwHighDateTime)*429496.7296)+
(((float)t->dwLowDateTime)*.0001) );
}
clock_t times(struct tms * t){
FILETIME ct = {0,0}, et = {0,0}, st = {0,0}, ut = {0,0}, rt = {0,0};
SYSTEMTIME realtime;
GetSystemTime( &realtime );
SystemTimeToFileTime( &realtime, &rt ); // get real time in 10^-9 sec
if( t != NULL ){
GetProcessTimes( GetCurrentProcess(), &ct, &et, &st, &ut);// get process time in 10^-9 sec
t->tms_utime = t->tms_cutime = filetime2msec(&ut);
t->tms_stime = t->tms_cstime = filetime2msec(&st);
}
return filetime2msec(&rt);
}
#endif /* WIN32 */
// Print timer status n ostream
ostream& operator << (ostream& os, const G4Timer& t)
{
if (t.IsValid())
{
os << "User=" << t.GetUserElapsed()
<< "s Real=" << t.GetRealElapsed()
<< "s Sys=" << t.GetSystemElapsed() << "s";
}
else
{
os << "User=****s Real=****s Sys=****s";
}
return os;
}
G4double G4Timer::GetRealElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetRealElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndRealTime-fStartRealTime;
return diff/sysconf(_SC_CLK_TCK);
}
G4double G4Timer::GetSystemElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetSystemElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndTimes.tms_stime-fStartTimes.tms_stime;
return diff/sysconf(_SC_CLK_TCK);
}
G4double G4Timer::GetUserElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetUserElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndTimes.tms_utime-fStartTimes.tms_utime;
return diff/sysconf(_SC_CLK_TCK);
}
@@ -0,0 +1,370 @@
// This code implementation is the intellectual property of
// the RD44 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: G4UnitsTable.cc,v 2.10 1998/12/02 09:50:27 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class implementation file
//
// For information related to this code contact:
// CERN, CN Division, ASD Group
//
// ------------ class G4UnitsTable ------------
//
// 17-05-98: first version, M.Maire
// 05-08-98: angstrom,microbarn,picobarn,petaelectronvolt
// 13-10-98: Units and symbols printed in fixed length
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4UnitsTable.hh"
#include <iomanip.h>
G4UnitsTable G4UnitDefinition::theUnitsTable;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitDefinition::G4UnitDefinition(G4String name, G4String symbol,
G4String category, G4double value)
{
Name = name;
SymbolName = symbol;
Value = value;
//
//does the Category objet already exist ?
size_t nbCat = theUnitsTable.entries();
size_t i = 0;
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
if (i == nbCat) theUnitsTable.insert( new G4UnitsCategory(category));
CategoryIndex = i;
//
//insert this Unit in the Unitstable
(theUnitsTable[CategoryIndex]->GetUnitsList()).insert(this);
//update string max length for name and symbol
theUnitsTable[i]->UpdateNameMxLen((G4int)name.length());
theUnitsTable[i]->UpdateSymbMxLen((G4int)symbol.length());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitDefinition::~G4UnitDefinition()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitDefinition::G4UnitDefinition(G4UnitDefinition& right)
{
*this = right;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4UnitDefinition & G4UnitDefinition::operator=(const G4UnitDefinition& right)
{
return right;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4UnitDefinition::operator==(const G4UnitDefinition& right) const
{
return (this == (G4UnitDefinition *) &right);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4UnitDefinition::operator!=(const G4UnitDefinition &right) const
{
return (this != (G4UnitDefinition *) &right);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4UnitDefinition::GetValueOf(G4String string)
{
if(theUnitsTable.entries()==0) BuildUnitsTable();
G4String name,symbol;
for (G4int i=0;i<theUnitsTable.entries();i++)
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (G4int j=0;j<units.entries();j++)
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(string==name||string==symbol)
return units[j]->GetValue();
}
}
G4cout << "Warning from G4UnitDefinition::GetValueOf(" << string << ")."
<< " The unit " << string << " does not exist in UnitsTable."
<< " Return Value = 0." << endl;
return 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4String G4UnitDefinition::GetCategory(G4String string)
{
if(theUnitsTable.entries()==0) BuildUnitsTable();
G4String name,symbol;
for (G4int i=0;i<theUnitsTable.entries();i++)
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (G4int j=0;j<units.entries();j++)
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(string==name||string==symbol)
return theUnitsTable[i]->GetName();
}
}
G4cout << "Warning from G4UnitDefinition::GetCategory(" << string << ")."
<< " The unit " << string << " does not exist in UnitsTable."
<< " Return category = None" << endl;
return "None";
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4UnitDefinition::PrintDefinition()
{
G4int nameL = theUnitsTable[CategoryIndex]->GetNameMxLen();
G4int symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen();
G4cout << setw(nameL) << Name << " ("
<< setw(symbL) << SymbolName << ") = " << Value << endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4UnitDefinition::BuildUnitsTable()
{
//Length
new G4UnitDefinition( "kilometer","km" ,"Length",kilometer);
new G4UnitDefinition( "meter","m" ,"Length",meter);
new G4UnitDefinition("centimeter","cm" ,"Length",centimeter);
new G4UnitDefinition("millimeter","mm" ,"Length",millimeter);
new G4UnitDefinition("micrometer","mum" ,"Length",micrometer);
new G4UnitDefinition( "nanometer","nm" ,"Length",nanometer);
new G4UnitDefinition( "angstrom","Ang" ,"Length",angstrom);
new G4UnitDefinition( "fermi","fm" ,"Length",fermi);
//Surface
new G4UnitDefinition( "kilometer2","km2" ,"Surface",kilometer2);
new G4UnitDefinition( "meter2","m2" ,"Surface",meter2);
new G4UnitDefinition("centimeter2","cm2" ,"Surface",centimeter2);
new G4UnitDefinition("millimeter2","mm2" ,"Surface",millimeter2);
new G4UnitDefinition( "barn","barn" ,"Surface",barn);
new G4UnitDefinition( "millibarn","mbarn" ,"Surface",millibarn);
new G4UnitDefinition( "microbarn","mubarn" ,"Surface",microbarn);
new G4UnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn);
new G4UnitDefinition( "picobarn","pbarn" ,"Surface",picobarn);
//Volume
new G4UnitDefinition( "kilometer3","km3" ,"Volume",kilometer3);
new G4UnitDefinition( "meter3","m3" ,"Volume",meter3);
new G4UnitDefinition("centimeter3","cm3" ,"Volume",centimeter3);
new G4UnitDefinition("millimeter3","mm3" ,"Volume",millimeter3);
//Angle
new G4UnitDefinition( "radian","rad" ,"Angle",radian);
new G4UnitDefinition("milliradian","mrad" ,"Angle",milliradian);
new G4UnitDefinition( "steradian","sr" ,"Angle",steradian);
new G4UnitDefinition( "degree","deg" ,"Angle",degree);
//Time
new G4UnitDefinition( "second","s" ,"Time",second);
new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
new G4UnitDefinition("microsecond","mus" ,"Time",microsecond);
new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);
//Frequency
new G4UnitDefinition( "hertz","Hz" ,"Frequency",hertz);
new G4UnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz);
new G4UnitDefinition("megahertz","MHz" ,"Frequency",megahertz);
//Electric charge
new G4UnitDefinition( "eplus","e+" ,"Electric charge",eplus);
new G4UnitDefinition("coulomb","C" ,"Electric charge",coulomb);
//Energy
new G4UnitDefinition( "electronvolt","eV" ,"Energy",electronvolt);
new G4UnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt);
new G4UnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt);
new G4UnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt);
new G4UnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt);
new G4UnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt);
new G4UnitDefinition( "joule","J" ,"Energy",joule);
//Mass
new G4UnitDefinition("milligram","mg","Mass",milligram);
new G4UnitDefinition( "gram","g" ,"Mass",gram);
new G4UnitDefinition( "kilogram","kg","Mass",kilogram);
//Volumic Mass
new G4UnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3);
new G4UnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3);
//Power
new G4UnitDefinition("watt","W","Power",watt);
//Force
new G4UnitDefinition("newton","N","Force",newton);
//Pressure
new G4UnitDefinition( "pascal","Pa" ,"Pressure",pascal);
new G4UnitDefinition( "bar","bar","Pressure",bar);
new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere);
//Electric current
new G4UnitDefinition( "ampere","A" ,"Electric current",ampere);
new G4UnitDefinition("milliampere","mA" ,"Electric current",milliampere);
new G4UnitDefinition("microampere","muA","Electric current",microampere);
new G4UnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere);
//Electric potential
new G4UnitDefinition( "volt","V" ,"Electric potential",volt);
new G4UnitDefinition("kilovolt","kV","Electric potential",kilovolt);
new G4UnitDefinition("megavolt","MV","Electric potential",megavolt);
//Magnetic flux
new G4UnitDefinition("weber","Wb","Magnetic flux",weber);
//Magnetic flux density
new G4UnitDefinition( "tesla","T" ,"Magnetic flux density",tesla);
new G4UnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss);
new G4UnitDefinition( "gauss","G" ,"Magnetic flux density",gauss);
//Temperature
new G4UnitDefinition("kelvin","K","Temperature",kelvin);
//Amount of substance
new G4UnitDefinition("mole","mol","Amount of substance",mole);
//Activity
new G4UnitDefinition("becquerel","Bq","Activity",becquerel);
new G4UnitDefinition( "curie","Ci","Activity",curie);
//Dose
new G4UnitDefinition("gray","Gy","Dose",gray);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4UnitDefinition::PrintUnitsTable()
{
G4cout << "\n ----- The Table of Units ----- \n";
for(size_t i=0;i<theUnitsTable.entries();i++)
theUnitsTable[i]->PrintCategory();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitsCategory::G4UnitsCategory(G4String name)
{
Name = name;
UnitsList = *(new G4UnitsContainer);
NameMxLen = 0;
SymbMxLen = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitsCategory::~G4UnitsCategory()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitsCategory::G4UnitsCategory(G4UnitsCategory& right)
{
*this = right;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4UnitsCategory & G4UnitsCategory::operator=(const G4UnitsCategory& right)
{
return right;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4UnitsCategory::operator==(const G4UnitsCategory& right) const
{
return (this == (G4UnitsCategory *) &right);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4UnitsCategory::operator!=(const G4UnitsCategory &right) const
{
return (this != (G4UnitsCategory *) &right);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4UnitsCategory::PrintCategory()
{
G4cout << "\n category: " << Name << endl;
for(size_t i=0;i<UnitsList.entries();i++)
UnitsList[i]->PrintDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::G4BestUnit(G4double value,G4String category)
{
// find the category
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
size_t nbCat = theUnitsTable.entries();
size_t i = 0;
while
((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
if (i == nbCat)
{ G4cout << " G4BestUnit: the category " << category
<< " does not exist; --> G4Exception" << endl;
G4Exception(" ");
}
//
IndexOfCategory = i;
Value = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::~G4BestUnit()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
ostream& operator<<(ostream& flux, G4BestUnit a)
{
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
G4UnitsContainer& List = theUnitsTable[a.IndexOfCategory]
->GetUnitsList();
G4int len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
G4int ksup(-1), kinf(-1);
G4double dsup(DBL_MAX), dinf(-DBL_MAX);
for (G4int k=0; k<List.entries(); k++)
{
G4double diff = fabs(a.Value) - (List[k]->GetValue());
if ((diff>=0.)&&(diff<=dsup)) { ksup=k; dsup=diff;}
if ((diff< 0.)&&(diff>=dinf)) { kinf=k; dinf=diff;}
}
G4int index=ksup; if(ksup==-1) index=kinf;
flux << a.Value/(List[index]->GetValue()) << " " << setw(len)
<< List[index]->GetSymbol();
return flux;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+16
View File
@@ -0,0 +1,16 @@
//History 1998 Nov. 3 Masayasu Nagamatu
#include "G4ios.hh"
#ifdef G4STREAM
#include "G4strstreambuf.hh"
G4strstreambuf G4coutbuf;
G4strstreambuf G4cerrbuf;
ostream G4cout(&G4coutbuf);
ostream G4cerr(&G4cerrbuf);
#endif