Import Geant4 7.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 12:11:21 +02:00
parent 516dbf1a58
commit d93e1e39a9
5384 changed files with 125662 additions and 82444 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4AllocatorPool.cc,v 1.2 2004/11/12 16:25:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4AllocatorPool.cc,v 1.3 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ----------------------------------------------------------------------
@@ -41,11 +41,9 @@
//
G4AllocatorPool::G4AllocatorPool( unsigned int sz )
: esize(sz<sizeof(G4PoolLink) ? sizeof(G4PoolLink) : sz),
csize(sz<1024/2-16 ? 1024-16 : sz*10-16)
csize(sz<1024/2-16 ? 1024-16 : sz*10-16),
chunks(0), head(0), nchunks(0)
{
chunks = 0;
head = 0;
nchunks = 0;
}
// ************************************************************
@@ -65,7 +63,7 @@ G4AllocatorPool::G4AllocatorPool(const G4AllocatorPool& right)
G4AllocatorPool&
G4AllocatorPool::operator= (const G4AllocatorPool& right)
{
if (&right == this) return *this;
if (&right == this) { return *this; }
chunks = right.chunks;
head = right.head;
nchunks = right.nchunks;
+20 -14
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4DataVector.cc,v 1.6 2003/06/06 16:17:16 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4DataVector.cc,v 1.7 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------
@@ -59,7 +59,8 @@ G4DataVector::~G4DataVector()
G4bool G4DataVector::Store(std::ofstream& fOut, G4bool ascii)
{
// Ascii mode
if (ascii) {
if (ascii)
{
fOut << *this;
return true;
}
@@ -70,7 +71,8 @@ G4bool G4DataVector::Store(std::ofstream& fOut, G4bool ascii)
G4double* value = new G4double[sizeV];
size_t i=0;
for (const_iterator itr=begin(); itr!=end(); itr++, i++){
for (const_iterator itr=begin(); itr!=end(); itr++, i++)
{
value[i] = *itr;
}
fOut.write((char*)(value), sizeV*(sizeof (G4double)) );
@@ -82,19 +84,21 @@ G4bool G4DataVector::Store(std::ofstream& fOut, G4bool ascii)
G4bool G4DataVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
clear();
size_t sizeV;
size_t sizeV=0;
// retrieve in ascii mode
if (ascii) {
if (ascii)
{
// contents
fIn >> sizeV;
if (fIn.fail()) return false;
if (fIn.fail()) { return false; }
reserve(sizeV);
for(size_t i = 0; i < sizeV ; i++) {
G4double vData;
for(size_t i = 0; i < sizeV ; i++)
{
G4double vData=0.0;
fIn >> vData;
if (fIn.fail()) return false;
if (fIn.fail()) { return false; }
push_back(vData);
}
return true ;
@@ -105,13 +109,15 @@ G4bool G4DataVector::Retrieve(std::ifstream& fIn, G4bool ascii)
G4double* value = new G4double[sizeV];
fIn.read((char*)(value), sizeV*(sizeof(G4double)) );
if (G4int(fIn.gcount()) != G4int(sizeV*(sizeof(G4double))) ){
if (G4int(fIn.gcount()) != G4int(sizeV*(sizeof(G4double))) )
{
delete [] value;
return false;
}
reserve(sizeV);
for(size_t i = 0; i < sizeV; i++) {
for(size_t i = 0; i < sizeV; i++)
{
push_back(value[i]);
}
delete [] value;
@@ -120,9 +126,9 @@ G4bool G4DataVector::Retrieve(std::ifstream& fIn, G4bool ascii)
std::ostream& operator<<(std::ostream& out, const G4DataVector& pv)
{
size_t i;
out << pv.size() << G4endl;
for(i = 0; i < pv.size(); i++) {
for(size_t i = 0; i < pv.size(); i++)
{
out << std::setprecision(12) << pv[i] << G4endl;
}
+13 -10
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Exception.cc,v 1.18 2004/11/12 16:25:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4Exception.cc,v 1.19 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ----------------------------------------------------------------------
@@ -40,14 +40,14 @@
void G4Exception(const char* s)
{
if(s)
{
G4cerr << s << G4endl;
}
if(G4StateManager::GetStateManager()->SetNewState(G4State_Abort,s)) {
if(s) { G4cerr << s << G4endl; }
if(G4StateManager::GetStateManager()->SetNewState(G4State_Abort,s))
{
G4cerr << G4endl << "*** G4Exception: Aborting execution ***" << G4endl;
abort();
} else {
}
else
{
G4cerr << G4endl << "*** G4Exception: Abortion suppressed ***"
<< G4endl << "*** No guarantee for further execution ***" << G4endl;
}
@@ -98,10 +98,13 @@ void G4Exception(const char* originOfException,
}
if(toBeAborted)
{
if(G4StateManager::GetStateManager()->SetNewState(G4State_Abort)) {
if(G4StateManager::GetStateManager()->SetNewState(G4State_Abort))
{
G4cerr << G4endl << "*** G4Exception: Aborting execution ***" << G4endl;
abort();
} else {
}
else
{
G4cerr << G4endl << "*** G4Exception: Abortion suppressed ***"
<< G4endl << "*** No guarantee for further execution ***" << G4endl;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.cc,v 1.8 2001/07/11 10:00:56 gunter Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4LPhysicsFreeVector.cc,v 1.9 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------------
@@ -41,17 +41,19 @@
#include <stdio.h>
G4LPhysicsFreeVector::G4LPhysicsFreeVector()
: verboseLevel(0)
{
type = T_G4LPhysicsFreeVector;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
verboseLevel = 0;
}
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin, G4double binmin,
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin,
G4double binmin,
G4double binmax)
: verboseLevel(0)
{
type = T_G4LPhysicsFreeVector;
@@ -63,8 +65,8 @@ G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin, G4double binmin,
lastBin = 0;
binVector.reserve(nbin);
dataVector.reserve(nbin);
verboseLevel = 0;
for (size_t i=0; i<numberOfBin; i++) {
for (size_t i=0; i<numberOfBin; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
@@ -76,8 +78,8 @@ 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);
for (size_t i = 0; i < numberOfBin; i++)
{
printf(" %12.4f %7.1f\n", binVector[i], dataVector[i]/millibarn);
}
}
+48 -33
View File
@@ -21,14 +21,14 @@
// ********************************************************************
//
//
// $Id: G4OrderedTable.cc,v 1.3 2003/06/06 16:17:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4OrderedTable.cc,v 1.4 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
// GEANT 4 class implementation
//
// G4OrderedTable
// G4OrderedTable
//
// ------------------------------------------------------------
@@ -38,7 +38,6 @@
#include <fstream>
#include <iomanip>
G4OrderedTable::G4OrderedTable()
: std::vector<G4DataVector*>()
{
@@ -54,18 +53,19 @@ G4OrderedTable::~G4OrderedTable()
}
G4bool G4OrderedTable::Store(const G4String& fileName,
G4bool ascii)
G4bool ascii)
{
std::ofstream fOut;
// open output file //
if (!ascii)
fOut.open(fileName, std::ios::out|std::ios::binary);
{ fOut.open(fileName, std::ios::out|std::ios::binary); }
else
fOut.open(fileName, std::ios::out);
{ fOut.open(fileName, std::ios::out); }
// check if the file has been opened successfully
if (!fOut) {
if (!fOut)
{
#ifdef G4VERBOSE
G4cerr << "G4OrderedTable::::Store ";
G4cerr << " Can not open file " << fileName << G4endl;
@@ -76,19 +76,25 @@ G4bool G4OrderedTable::Store(const G4String& fileName,
// Number of elements
size_t tableSize = size();
if (!ascii){
if (!ascii)
{
fOut.write( (char*)(&tableSize), sizeof tableSize);
} else {
}
else
{
fOut << tableSize << G4endl;
}
// Data Vector
G4OrderedTableIterator itr;
G4int vType = G4DataVector::T_G4DataVector;
for (itr=begin(); itr!=end(); ++itr) {
if (!ascii){
for (G4OrderedTableIterator itr=begin(); itr!=end(); ++itr)
{
if (!ascii)
{
fOut.write( (char*)(&vType), sizeof vType);
} else {
}
else
{
fOut << vType << G4endl;
}
(*itr)->Store(fOut,ascii);
@@ -100,17 +106,18 @@ G4bool G4OrderedTable::Store(const G4String& fileName,
G4bool G4OrderedTable::Retrieve(const G4String& fileName,
G4bool ascii)
G4bool ascii)
{
std::ifstream fIn;
// open input file //
if (ascii)
fIn.open(fileName,std::ios::in|std::ios::binary);
{ fIn.open(fileName,std::ios::in|std::ios::binary); }
else
fIn.open(fileName,std::ios::in);
{ fIn.open(fileName,std::ios::in); }
// check if the file has been opened successfully
if (!fIn) {
if (!fIn)
{
#ifdef G4VERBOSE
G4cerr << "G4OrderedTable::Retrieve ";
G4cerr << " Can not open file " << fileName << G4endl;
@@ -123,23 +130,31 @@ G4bool G4OrderedTable::Retrieve(const G4String& fileName,
clearAndDestroy();
// Number of elements
size_t tableSize;
if (!ascii){
size_t tableSize=0;
if (!ascii)
{
fIn.read((char*)(&tableSize), sizeof tableSize);
} else {
}
else
{
fIn >> tableSize;
}
reserve(tableSize);
// Physics Vector
for (size_t idx=0; idx<tableSize; ++idx) {
G4int vType;
if (!ascii){
for (size_t idx=0; idx<tableSize; ++idx)
{
G4int vType=0;
if (!ascii)
{
fIn.read( (char*)(&vType), sizeof vType);
} else {
}
else
{
fIn >> vType;
}
if (vType != G4DataVector::T_G4DataVector) {
if (vType != G4DataVector::T_G4DataVector)
{
#ifdef G4VERBOSE
G4cerr << "G4OrderedTable::Retrieve ";
G4cerr << " illegal Data Vector type " << vType << " in ";
@@ -151,10 +166,12 @@ G4bool G4OrderedTable::Retrieve(const G4String& fileName,
G4DataVector* pVec = new G4DataVector;
if (! (pVec->Retrieve(fIn,ascii)) ){
if (! (pVec->Retrieve(fIn,ascii)) )
{
#ifdef G4VERBOSE
G4cerr << "G4OrderedTable::Retrieve ";
G4cerr << " error in retreiving " << idx << "-th Physics Vector from file ";
G4cerr << " error in retreiving " << idx
<< "-th Physics Vector from file ";
G4cerr << fileName << G4endl;
#endif
fIn.close();
@@ -169,12 +186,12 @@ G4bool G4OrderedTable::Retrieve(const G4String& fileName,
}
std::ostream& operator<<(std::ostream& out,
G4OrderedTable& right)
G4OrderedTable& right)
{
// Printout Data Vector
G4OrderedTableIterator itr;
size_t i=0;
for (itr=right.begin(); itr!=right.end(); ++itr) {
for (G4OrderedTableIterator itr=right.begin(); itr!=right.end(); ++itr)
{
out << std::setw(8) << i << "-th Vector ";
out << ": Type " << G4DataVector::T_G4DataVector << G4endl;
out << *(*itr);
@@ -183,5 +200,3 @@ std::ostream& operator<<(std::ostream& out,
out << G4endl;
return out;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsFreeVector.cc,v 1.8 2001/07/11 10:00:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4PhysicsFreeVector.cc,v 1.9 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
//--------------------------------------------------------------------
@@ -62,7 +62,8 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
dataVector.reserve(numberOfBin+1);
binVector.reserve(numberOfBin+1);
for (size_t i=0; i<=numberOfBin; i++) {
for (size_t i=0; i<=numberOfBin; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
@@ -73,7 +74,6 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
@@ -88,7 +88,8 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
dataVector.reserve(numberOfBin+1);
binVector.reserve(numberOfBin+1);
for (size_t i=0; i<numberOfBin; i++) {
for (size_t i=0; i<numberOfBin; i++)
{
binVector.push_back(theBinVector[i]);
dataVector.push_back(theDataVector[i]);
}
@@ -110,7 +111,6 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
@@ -118,13 +118,13 @@ G4PhysicsFreeVector::~G4PhysicsFreeVector(){}
void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue,
G4double theDataValue )
G4double theDataValue )
{
binVector[theBinNumber] = theBinValue;
dataVector[theBinNumber] = theDataValue;
if( theBinNumber == numberOfBin-1 ) {
if( theBinNumber == numberOfBin-1 )
{
edgeMax = binVector[numberOfBin-1];
// Put values to extra hidden bin. For 'binVector', the 'edgeMin'
@@ -139,7 +139,8 @@ void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue,
dataVector[numberOfBin] = theDataValue;
}
if( theBinNumber == 0 ) {
if( theBinNumber == 0 )
{
edgeMin = binVector[0];
}
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLinearVector.cc,v 1.10 2003/06/06 16:17:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4PhysicsLinearVector.cc,v 1.11 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
//--------------------------------------------------------------------
@@ -44,6 +44,7 @@
#include "G4PhysicsLinearVector.hh"
G4PhysicsLinearVector::G4PhysicsLinearVector()
: dBin(0.), baseBin(0.)
{
edgeMin = 0.0;
edgeMax = 0.0;
@@ -52,6 +53,7 @@ G4PhysicsLinearVector::G4PhysicsLinearVector()
}
G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
: dBin(0.), baseBin(0.)
{
type = T_G4PhysicsLinearVector;
@@ -61,8 +63,6 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = 0.;
baseBin = 0.;
edgeMin = 0.;
edgeMax = 0.;
@@ -71,7 +71,8 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
for (size_t i=0; i<=numberOfBin; i++) {
for (size_t i=0; i<=numberOfBin; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
@@ -79,6 +80,8 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
G4double theEmax, size_t theNbin)
: dBin((theEmax-theEmin)/theNbin),
baseBin(theEmin/dBin)
{
type = T_G4PhysicsLinearVector;
@@ -88,10 +91,9 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = (theEmax-theEmin) / numberOfBin;
baseBin = theEmin/dBin;
for (size_t i=0; i<numberOfBin+1; i++) {
for (size_t i=0; i<numberOfBin+1; i++)
{
binVector.push_back( theEmin + i*dBin );
dataVector.push_back(0.0);
}
@@ -106,15 +108,14 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
G4PhysicsLinearVector::~G4PhysicsLinearVector(){}
G4bool G4PhysicsLinearVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
if (success){
if (success)
{
G4double theEmin = binVector[0];
dBin = binVector[1]-theEmin;
baseBin = theEmin/dBin;
}
return success;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLnVector.cc,v 1.13 2004/11/12 17:38:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4PhysicsLnVector.cc,v 1.14 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------
@@ -45,8 +45,8 @@ G4PhysicsLnVector::G4PhysicsLnVector()
type = T_G4PhysicsLnVector;
}
G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
: dBin(0.), baseBin(0.)
{
type = T_G4PhysicsLnVector;
@@ -56,8 +56,6 @@ G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = 0.;
baseBin = 0.;
edgeMin = 0.;
edgeMax = 0.;
@@ -66,15 +64,17 @@ G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin)
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
for (size_t i=0; i<=numberOfBin; i++) {
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)
G4double theEmax, size_t theNbin)
: dBin(std::log(theEmax/theEmin)/theNbin),
baseBin(std::log(theEmin)/dBin)
{
type = T_G4PhysicsLnVector;
@@ -84,10 +84,9 @@ G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin,
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = std::log(theEmax/theEmin) / numberOfBin;
baseBin = std::log(theEmin)/dBin;
for (size_t i=0; i<numberOfBin+1; i++) {
for (size_t i=0; i<numberOfBin+1; i++)
{
binVector.push_back(std::exp(std::log(theEmin)+i*dBin));
dataVector.push_back(0.0);
}
@@ -98,19 +97,18 @@ G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin,
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
}
}
G4PhysicsLnVector::~G4PhysicsLnVector(){}
G4bool G4PhysicsLnVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
if (success){
if (success)
{
G4double theEmin = binVector[0];
dBin = std::log(binVector[1]/theEmin);
baseBin = std::log(theEmin)/dBin;
}
return success;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLogVector.cc,v 1.11 2004/11/12 17:38:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4PhysicsLogVector.cc,v 1.12 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------
@@ -42,15 +42,14 @@
#include "G4PhysicsLogVector.hh"
G4PhysicsLogVector::G4PhysicsLogVector()
: dBin(0.), baseBin(0.)
{
type = T_G4PhysicsLogVector;
}
G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
: dBin(0.), baseBin(0.)
{
type = T_G4PhysicsLogVector;
@@ -60,8 +59,6 @@ G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = 0.;
baseBin = 0.;
edgeMin = 0.;
edgeMax = 0.;
@@ -70,15 +67,17 @@ G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
for (size_t i=0; i<=numberOfBin; i++) {
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)
: dBin(std::log10(theEmax/theEmin)/theNbin),
baseBin(std::log10(theEmin)/dBin)
{
type = T_G4PhysicsLogVector;
@@ -88,10 +87,9 @@ G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
binVector.reserve(theNbin+1);
numberOfBin = theNbin;
dBin = std::log10(theEmax/theEmin) / numberOfBin;
baseBin = std::log10(theEmin)/dBin;
for (size_t i=0; i<numberOfBin+1; i++) {
for (size_t i=0; i<numberOfBin+1; i++)
{
binVector.push_back(std::pow(10., std::log10(theEmin)+i*dBin));
dataVector.push_back(0.0);
}
@@ -104,17 +102,16 @@ G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
lastValue = DBL_MAX;
}
G4PhysicsLogVector::~G4PhysicsLogVector(){}
G4bool G4PhysicsLogVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
if (success){
if (success)
{
G4double theEmin = binVector[0];
dBin = std::log10(binVector[1]/theEmin);
baseBin = std::log10(theEmin)/dBin;
}
return success;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.8 2001/07/11 10:00:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4PhysicsOrderedFreeVector.cc,v 1.9 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Implementation
@@ -55,23 +55,23 @@
/////////////////
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
G4double *Values,
size_t VectorLength)
G4double *Values,
size_t VectorLength)
{
type = T_G4PhysicsOrderedFreeVector;
lastBin = INT_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
numberOfBin = VectorLength;
numberOfBin = VectorLength;
for (size_t i = 0 ; i < VectorLength ; i++)
{
binVector.push_back(Energies[i]);
dataVector.push_back(Values[i]);
}
for (size_t i = 0 ; i < VectorLength ; i++)
{
binVector.push_back(Energies[i]);
dataVector.push_back(Values[i]);
}
edgeMin = binVector.front();
edgeMax = binVector.back();
}
@@ -84,9 +84,9 @@ G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
lastEnergy = -DBL_MAX;
lastValue = DBL_MAX;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
edgeMin = 0.0;
edgeMax = 0.0;
numberOfBin = 0;
}
////////////////
@@ -104,7 +104,7 @@ G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
{
binVector.push_back(energy);
dataVector.push_back(value);
numberOfBin++;
numberOfBin++;
edgeMin = binVector.front();
edgeMax = binVector.back();
@@ -113,23 +113,23 @@ G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
G4double
G4PhysicsOrderedFreeVector::GetLowEdgeEnergy(size_t binNumber) const
{
return binVector[binNumber];
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);
if (aValue <= GetMinValue()) {
return GetMinLowEdgeEnergy();
} else if (aValue >= GetMaxValue()) {
return GetMaxLowEdgeEnergy();
} else {
size_t closestBin = FindValueBinLocation(aValue);
G4double theEnergy = LinearInterpolationOfEnergy(aValue, closestBin);
return theEnergy;
}
return theEnergy;
}
}
size_t
@@ -140,9 +140,9 @@ G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
G4int n3 = numberOfBin - 1;
while (n1 != n3 - 1) {
if (aValue > dataVector[n2])
n1 = n2;
{ n1 = n2; }
else
n3 = n2;
{ n3 = n2; }
n2 = n1 + (n3 - n1 + 1)/2;
}
return (size_t)n1;
@@ -150,7 +150,7 @@ G4PhysicsOrderedFreeVector::FindValueBinLocation(G4double aValue)
G4double
G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(G4double aValue,
size_t theLocBin)
size_t theLocBin)
{
G4double intplFactor = (aValue-dataVector[theLocBin])
/ (dataVector[theLocBin+1]-dataVector[theLocBin]); // Interpolation factor
+60 -46
View File
@@ -21,14 +21,14 @@
// ********************************************************************
//
//
// $Id: G4PhysicsTable.cc,v 1.12 2004/10/29 11:38:08 kurasige Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4PhysicsTable.cc,v 1.13 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
// GEANT 4 class implementation
//
// G4PhysicsTable
// G4PhysicsTable
//
// ------------------------------------------------------------
@@ -60,9 +60,10 @@ G4PhysicsTable& G4PhysicsTable::operator=(const G4PhysicsTable& right)
{
if (this != &right)
{
G4PhysCollection::const_iterator itr;
size_t idx = 0;
for (itr=right.begin(); itr!=right.end(); ++itr ) {
for (G4PhysCollection::const_iterator itr=right.begin();
itr!=right.end(); ++itr )
{
G4PhysCollection::push_back(*itr);
vecFlag.push_back(right.GetFlag(idx));
idx +=1;
@@ -83,20 +84,20 @@ void G4PhysicsTable::resize(size_t size, G4PhysicsVector* vec)
vecFlag.resize(size, true);
}
G4bool G4PhysicsTable::StorePhysicsTable(const G4String& fileName,
G4bool ascii)
G4bool ascii)
{
std::ofstream fOut;
// open output file //
if (!ascii)
fOut.open(fileName, std::ios::out|std::ios::binary);
{ fOut.open(fileName, std::ios::out|std::ios::binary); }
else
fOut.open(fileName, std::ios::out);
{ fOut.open(fileName, std::ios::out); }
// check if the file has been opened successfully
if (!fOut) {
if (!fOut)
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsTable::StorePhysicsTable ";
G4cerr << " Can not open file " << fileName << G4endl;
@@ -107,19 +108,25 @@ G4bool G4PhysicsTable::StorePhysicsTable(const G4String& fileName,
// Number of elements
size_t tableSize = size();
if (!ascii){
if (!ascii)
{
fOut.write( (char*)(&tableSize), sizeof tableSize);
} else {
}
else
{
fOut << tableSize << G4endl;
}
// Physics Vector
G4PhysicsTableIterator itr;
for (itr=begin(); itr!=end(); ++itr) {
for (G4PhysicsTableIterator itr=begin(); itr!=end(); ++itr)
{
G4int vType = (*itr)->GetType();
if (!ascii){
if (!ascii)
{
fOut.write( (char*)(&vType), sizeof vType);
} else {
}
else
{
fOut << vType << G4endl;
}
(*itr)->Store(fOut,ascii);
@@ -137,7 +144,8 @@ G4bool G4PhysicsTable::ExistPhysicsTable(const G4String& fileName) const
fIn.open(fileName,std::ios::in);
// check if the file has been opened successfully
if (!fIn) {
if (!fIn)
{
value = false;
}
fIn.close();
@@ -145,17 +153,18 @@ G4bool G4PhysicsTable::ExistPhysicsTable(const G4String& fileName) const
}
G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
G4bool ascii)
G4bool ascii)
{
std::ifstream fIn;
// open input file
if (ascii)
fIn.open(fileName,std::ios::in|std::ios::binary);
{ fIn.open(fileName,std::ios::in|std::ios::binary); }
else
fIn.open(fileName,std::ios::in);
{ fIn.open(fileName,std::ios::in);}
// check if the file has been opened successfully
if (!fIn) {
if (!fIn)
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
G4cerr << " Can not open file " << fileName << G4endl;
@@ -168,25 +177,33 @@ G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
clearAndDestroy();
// Number of elements
size_t tableSize;
if (!ascii){
size_t tableSize=0;
if (!ascii)
{
fIn.read((char*)(&tableSize), sizeof tableSize);
} else {
}
else
{
fIn >> tableSize;
}
reserve(tableSize);
vecFlag.clear();
// Physics Vector
for (size_t idx=0; idx<tableSize; ++idx) {
G4int vType;
if (!ascii){
for (size_t idx=0; idx<tableSize; ++idx)
{
G4int vType=0;
if (!ascii)
{
fIn.read( (char*)(&vType), sizeof vType);
} else {
}
else
{
fIn >> vType;
}
G4PhysicsVector* pVec = CreatePhysicsVector(vType);
if (pVec==0) {
if (pVec==0)
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
G4cerr << " illegal Physics Vector type " << vType << " in ";
@@ -196,7 +213,8 @@ G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
return false;
}
if (! (pVec->Retrieve(fIn,ascii)) ){
if (! (pVec->Retrieve(fIn,ascii)) )
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsTable::RetrievePhysicsTable ";
G4cerr << " error in retreiving " << idx << "-th Physics Vector from file ";
@@ -216,18 +234,21 @@ G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
}
std::ostream& operator<<(std::ostream& out,
G4PhysicsTable& right)
G4PhysicsTable& right)
{
// Printout Physics Vector
G4PhysicsTableIterator itr;
size_t i=0;
for (itr=right.begin(); itr!=right.end(); ++itr) {
for (G4PhysicsTableIterator itr=right.begin(); itr!=right.end(); ++itr)
{
out << std::setw(8) << i << "-th Vector ";
out << ": Type " << G4int((*itr)->GetType()) ;
out << ": Flag ";
if (right.GetFlag(i)) {
if (right.GetFlag(i))
{
out << " T";
} else {
}
else
{
out << " F";
}
out << G4endl;
@@ -242,7 +263,8 @@ void G4PhysicsTable::ResetFlagArray()
{
size_t tableSize = G4PhysCollection::size();
vecFlag.clear();
for (size_t idx=0; idx<tableSize; idx++){
for (size_t idx=0; idx<tableSize; idx++)
{
vecFlag.push_back(true);
}
}
@@ -258,8 +280,8 @@ void G4PhysicsTable::ResetFlagArray()
G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
{
G4PhysicsVector* pVector=0;
switch (type) {
switch (type)
{
case T_G4PhysicsLinearVector:
pVector = new G4PhysicsLinearVector();
break;
@@ -286,14 +308,6 @@ G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
default:
break;
}
return pVector;
}
+22 -20
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.cc,v 1.15 2003/06/06 16:17:17 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4PhysicsVector.cc,v 1.16 2005/03/15 19:11:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------
@@ -44,10 +44,10 @@
#include <iomanip>
G4PhysicsVector::G4PhysicsVector()
: edgeMin(0.), edgeMax(0.), numberOfBin(0),
: type(T_G4PhysicsVector),
edgeMin(0.), edgeMax(0.), numberOfBin(0),
lastEnergy(0.), lastValue(0.), lastBin(0)
{
type = T_G4PhysicsVector;
}
G4PhysicsVector::~G4PhysicsVector()
@@ -62,11 +62,10 @@ G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right)
*this=right;
}
G4PhysicsVector&
G4PhysicsVector::operator=(const G4PhysicsVector& right)
G4PhysicsVector& G4PhysicsVector::operator=(const G4PhysicsVector& right)
{
if (&right==this) return *this;
if (type != right.type) return *this;
if (&right==this) { return *this; }
if (type != right.type) { return *this; }
type = right.type;
edgeMin = right.edgeMin;
@@ -99,7 +98,8 @@ G4double G4PhysicsVector::GetLowEdgeEnergy(size_t binNumber) const
G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii)
{
// Ascii mode
if (ascii) {
if (ascii)
{
fOut << *this;
return true;
}
@@ -115,7 +115,8 @@ G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii)
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];
}
@@ -136,21 +137,23 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
comment = "";
// retrieve in ascii mode
if (ascii) {
if (ascii)
{
// binning
fIn >> edgeMin >> edgeMax >> numberOfBin;
if (fIn.fail()) return false;
if (fIn.fail()) { return false; }
// contents
size_t size;
size_t size=0;
fIn >> size;
if (fIn.fail()) return false;
if (fIn.fail()) { return false; }
binVector.reserve(size);
dataVector.reserve(size);
for(size_t i = 0; i < size ; i++) {
G4double vBin, vData;
for(size_t i = 0; i < size ; i++)
{
G4double vBin=0., vData=0.;
fIn >> vBin >> vData;
if (fIn.fail()) return false;
if (fIn.fail()) { return false; }
binVector.push_back(vBin);
dataVector.push_back(vData);
}
@@ -191,12 +194,11 @@ std::ostream& operator<<(std::ostream& out, const G4PhysicsVector& pv)
out <<" " << pv.edgeMax <<" " << pv.numberOfBin << G4endl;
// contents
size_t i;
out << pv.dataVector.size() << G4endl;
for(i = 0; i < pv.dataVector.size(); i++) {
for(size_t i = 0; i < pv.dataVector.size(); i++)
{
out << std::setprecision(12) << pv.binVector[i] << " "
<< pv.dataVector[i] << G4endl;
}
return out;
}
+38 -24
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4StateManager.cc,v 1.10 2003/10/31 17:44:47 asaim Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4StateManager.cc,v 1.11 2005/03/15 19:11:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
@@ -35,6 +35,7 @@
#include "G4StateManager.hh"
// Initialization of the static pointer of the single class instance
//
G4StateManager* G4StateManager::theStateManager = 0;
G4StateManager::G4StateManager()
@@ -60,31 +61,42 @@ G4StateManager::~G4StateManager()
{
if (*i==state)
{
theDependentsList.erase(i);
i--;
theDependentsList.erase(i);
i--;
}
}
if ( state ) delete state;
if ( state ) { delete state; }
}
}
// -------------------------------------------------------------------------
// No matter how copy-constructor and operators below are implemented ...
// just dummy implementations, since not relevant for the singleton and
// declared private.
//
G4StateManager::G4StateManager(const G4StateManager &right)
: theCurrentState(right.theCurrentState),
thePreviousState(right.thePreviousState),
theDependentsList(right.theDependentsList),
theBottomDependent(right.theBottomDependent)
theBottomDependent(right.theBottomDependent),
suppressAbortion(right.suppressAbortion),
msgptr(right.msgptr),
exceptionHandler(right.exceptionHandler)
{
}
G4StateManager&
G4StateManager::operator=(const G4StateManager &right)
{
if (&right == this) return *this;
if (&right == this) { return *this; }
theCurrentState = right.theCurrentState;
thePreviousState = right.thePreviousState;
theDependentsList = right.theDependentsList;
theBottomDependent = right.theBottomDependent;
suppressAbortion = right.suppressAbortion;
msgptr = right.msgptr;
exceptionHandler = right.exceptionHandler;
return *this;
}
@@ -100,7 +112,8 @@ G4StateManager::operator!=(const G4StateManager &right) const
{
return (this != &right);
}
//
// -------------------------------------------------------------------------
G4StateManager*
G4StateManager::GetStateManager()
@@ -135,14 +148,14 @@ G4bool
G4StateManager::DeregisterDependent(G4VStateDependent* aDependent)
{
G4VStateDependent* tmp = 0;
std::vector<G4VStateDependent*>::iterator i;
for (i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
for (std::vector<G4VStateDependent*>::iterator i=theDependentsList.begin();
i!=theDependentsList.end(); i++)
{
if (**i==*aDependent)
{
tmp = *i;
theDependentsList.erase(i);
}
{
tmp = *i;
theDependentsList.erase(i);
}
}
return (tmp != 0);
}
@@ -166,9 +179,10 @@ G4StateManager::SetNewState(G4ApplicationState requestedState)
G4bool
G4StateManager::SetNewState(G4ApplicationState requestedState, const char* msg)
{
if(requestedState==G4State_Abort && suppressAbortion>0) {
if(suppressAbortion==2) return false;
if(theCurrentState==G4State_EventProc) return false;
if(requestedState==G4State_Abort && suppressAbortion>0)
{
if(suppressAbortion==2) { return false; }
if(theCurrentState==G4State_EventProc) { return false; }
}
msgptr = msg;
size_t i=0;
@@ -199,14 +213,14 @@ G4VStateDependent*
G4StateManager::RemoveDependent(const G4VStateDependent* aDependent)
{
G4VStateDependent* tmp = 0;
std::vector<G4VStateDependent*>::iterator i;
for (i=theDependentsList.begin(); i!=theDependentsList.end(); i++)
for (std::vector<G4VStateDependent*>::iterator i=theDependentsList.begin();
i!=theDependentsList.end(); i++)
{
if (**i==*aDependent)
{
tmp = *i;
theDependentsList.erase(i);
}
{
tmp = *i;
theDependentsList.erase(i);
}
}
return tmp;
}
@@ -232,7 +246,7 @@ G4StateManager::GetStateString(G4ApplicationState aState) const
case G4State_Abort:
stateName = "Abort"; break;
default:
stateName = "Unknown";
stateName = "Unknown"; break;
}
return stateName;
}
+24 -19
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Timer.cc,v 1.13 2004/11/22 08:14:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4Timer.cc,v 1.14 2005/03/15 19:11:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ----------------------------------------------------------------------
@@ -81,24 +81,29 @@ void G4Exception(const char* s=0);
std::ostream& operator << (std::ostream& os, const G4Timer& t)
{
if (t.IsValid())
{
os << "User=" << t.GetUserElapsed()
<< "s Real=" << t.GetRealElapsed()
<< "s Sys=" << t.GetSystemElapsed() << "s";
}
{
os << "User=" << t.GetUserElapsed()
<< "s Real=" << t.GetRealElapsed()
<< "s Sys=" << t.GetSystemElapsed() << "s";
}
else
{
os << "User=****s Real=****s Sys=****s";
}
{
os << "User=****s Real=****s Sys=****s";
}
return os;
}
G4Timer::G4Timer()
: fValidTimes(false)
{
}
G4double G4Timer::GetRealElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetRealElapsed - Timer not stopped or times not recorded");
}
{
G4Exception("G4Timer::GetRealElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndRealTime-fStartRealTime;
return diff/sysconf(_SC_CLK_TCK);
}
@@ -107,9 +112,9 @@ G4double G4Timer::GetRealElapsed() const
G4double G4Timer::GetSystemElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetSystemElapsed - Timer not stopped or times not recorded");
}
{
G4Exception("G4Timer::GetSystemElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndTimes.tms_stime-fStartTimes.tms_stime;
return diff/sysconf(_SC_CLK_TCK);
}
@@ -117,9 +122,9 @@ G4double G4Timer::GetSystemElapsed() const
G4double G4Timer::GetUserElapsed() const
{
if (!fValidTimes)
{
G4Exception("G4Timer::GetUserElapsed - Timer not stopped or times not recorded");
}
{
G4Exception("G4Timer::GetUserElapsed - Timer not stopped or times not recorded");
}
G4double diff=fEndTimes.tms_utime-fStartTimes.tms_utime;
return diff/sysconf(_SC_CLK_TCK);
}
+67 -43
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4UnitsTable.cc,v 1.22 2004/11/12 17:38:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
// $Id: G4UnitsTable.cc,v 1.26 2005/03/21 18:34:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//
@@ -35,26 +35,28 @@
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4UnitsTable.hh"
#include <iomanip>
#include <sstream>
G4UnitsTable G4UnitDefinition::theUnitsTable;
G4UnitsTable G4UnitDefinition::theUnitsTable;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4UnitDefinition::G4UnitDefinition(const G4String& name, const G4String& symbol,
const 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.size();
size_t i = 0;
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
if (i == nbCat) theUnitsTable.push_back( new G4UnitsCategory(category));
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
if (i == nbCat)
{ theUnitsTable.push_back( new G4UnitsCategory(category)); }
CategoryIndex = i;
//
//insert this Unit in the Unitstable
@@ -121,19 +123,21 @@ G4UnitsTable& G4UnitDefinition::GetUnitsTable()
G4double G4UnitDefinition::GetValueOf(const G4String& str)
{
if(theUnitsTable.size()==0) BuildUnitsTable();
if(theUnitsTable.size()==0) { BuildUnitsTable(); }
G4String name,symbol;
for (size_t i=0;i<theUnitsTable.size();i++)
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
{
G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j=0;j<units.size();j++)
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
{
name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(str==name||str==symbol)
return units[j]->GetValue();
{ return units[j]->GetValue(); }
}
}
G4cout << "Warning from G4UnitDefinition::GetValueOf(" << str << ")."
<< " The unit " << str << " does not exist in UnitsTable."
<< " Return Value = 0." << G4endl;
<< " The unit " << str << " does not exist in UnitsTable."
<< " Return Value = 0." << G4endl;
return 0.;
}
@@ -141,14 +145,16 @@ G4double G4UnitDefinition::GetValueOf(const G4String& str)
G4String G4UnitDefinition::GetCategory(const G4String& str)
{
if(theUnitsTable.size()==0) BuildUnitsTable();
if(theUnitsTable.size()==0) { BuildUnitsTable(); }
G4String name,symbol;
for (size_t i=0;i<theUnitsTable.size();i++)
{ G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
{
G4UnitsContainer& units = theUnitsTable[i]->GetUnitsList();
for (size_t j=0;j<units.size();j++)
{ name=units[j]->GetName(); symbol=units[j]->GetSymbol();
{
name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(str==name||str==symbol)
return theUnitsTable[i]->GetName();
{ return theUnitsTable[i]->GetName(); }
}
}
G4cout << "Warning from G4UnitDefinition::GetCategory(" << str << ")."
@@ -351,57 +357,70 @@ void G4UnitsCategory::PrintCategory()
{
G4cout << "\n category: " << Name << G4endl;
for(size_t i=0;i<UnitsList.size();i++)
UnitsList[i]->PrintDefinition();
{ UnitsList[i]->PrintDefinition(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::G4BestUnit(G4double value, const G4String& category)
: nbOfVals(1)
{
// find the category
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
size_t nbCat = theUnitsTable.size();
size_t i = 0;
while
((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
if (i == nbCat)
{ G4cout << " G4BestUnit: the category " << category
{
G4cout << " G4BestUnit: the category " << category
<< " does not exist !!" << G4endl;
G4Exception("Missing unit category !");
G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall",
FatalException, "Missing unit category !") ;
}
//
Value[0] = value;
Value[1] = 0.;
Value[2] = 0.;
IndexOfCategory = i;
nbOfVals = 1;
Value[0] = value; Value[1] = 0.; Value[2] = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::G4BestUnit(const G4ThreeVector& value, const G4String& category)
: nbOfVals(3)
{
// find the category
G4UnitsTable& theUnitsTable = G4UnitDefinition::GetUnitsTable();
size_t nbCat = theUnitsTable.size();
size_t i = 0;
while
((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) { i++; }
if (i == nbCat)
{ G4cerr << " G4BestUnit: the category " << category
{
G4cerr << " G4BestUnit: the category " << category
<< " does not exist." << G4endl;
G4Exception("Unit category not existing !");
G4Exception("G4BestUnit::G4BestUnit()", "InvalidCall",
FatalException, "Missing unit category !") ;
}
//
IndexOfCategory = i;
nbOfVals = 3;
Value[0] = value.x();
Value[1] = value.y();
Value[2] = value.z();
IndexOfCategory = i;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::~G4BestUnit()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4BestUnit::operator G4String () const
{
std::ostringstream oss;
oss << *this;
return oss.str();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
std::ostream& operator<<(std::ostream& flux, G4BestUnit a)
@@ -416,25 +435,31 @@ std::ostream& operator<<(std::ostream& flux, G4BestUnit a)
G4double rsup(DBL_MAX), rinf(0.);
//for a ThreeVector, choose the best unit for the biggest value
G4double value = std::max(std::max(std::fabs(a.Value[0]),std::fabs(a.Value[1])),
std::fabs(a.Value[2]));
G4double value = std::max(std::max(std::fabs(a.Value[0]),
std::fabs(a.Value[1])),
std::fabs(a.Value[2]));
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;}}
else if (value<=DBL_MIN) {if(unit<umin) {umin=unit; kinf=k;}}
else { G4double ratio = value/unit;
if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
}
if (!(value!=DBL_MAX))
{if(unit>umax) {umax=unit; ksup=k;}}
else if (value<=DBL_MIN)
{if(unit<umin) {umin=unit; kinf=k;}}
else
{
G4double ratio = value/unit;
if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
}
}
G4int index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
G4int index=ksup;
if(index==-1) { index=kinf; }
if(index==-1) { index=0; }
for (G4int j=0; j<a.nbOfVals; j++)
{flux << a.Value[j]/(List[index]->GetValue()) << " ";}
{ flux << a.Value[j]/(List[index]->GetValue()) << " "; }
std::ios::fmtflags oldform = flux.flags();
@@ -446,4 +471,3 @@ std::ostream& operator<<(std::ostream& flux, G4BestUnit a)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VExceptionHandler.cc,v 1.1 2002/08/19 18:20:12 asaim Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4VExceptionHandler.cc,v 1.2 2005/03/15 19:11:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
@@ -52,7 +52,7 @@ G4VExceptionHandler::G4VExceptionHandler(const G4VExceptionHandler &right)
G4VExceptionHandler& G4VExceptionHandler::operator=(const G4VExceptionHandler &right)
{
if (&right == this) return *this;
if (&right == this) { return *this; }
*this = right;
return *this;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VStateDependent.cc,v 1.3 2001/07/11 10:00:59 gunter Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4VStateDependent.cc,v 1.4 2005/03/15 19:11:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ------------------------------------------------------------
@@ -37,14 +37,14 @@
G4VStateDependent::G4VStateDependent(G4bool bottom)
{
G4StateManager * stateManager = G4StateManager::GetStateManager();
stateManager->RegisterDependent(this,bottom);
G4StateManager * stateManager = G4StateManager::GetStateManager();
stateManager->RegisterDependent(this,bottom);
}
G4VStateDependent::~G4VStateDependent()
{
G4StateManager * stateManager = G4StateManager::GetStateManager();
stateManager->DeregisterDependent(this);
G4StateManager * stateManager = G4StateManager::GetStateManager();
stateManager->DeregisterDependent(this);
}
G4VStateDependent::G4VStateDependent(const G4VStateDependent &right)
@@ -54,7 +54,7 @@ G4VStateDependent::G4VStateDependent(const G4VStateDependent &right)
G4VStateDependent& G4VStateDependent::operator=(const G4VStateDependent &right)
{
if (&right == this) return *this;
if (&right == this) { return *this; }
*this = right;
return *this;
}
@@ -0,0 +1,50 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4coutDestination.cc,v 1.1 2005/03/15 19:11:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// ----------------------------------------------------------------------
// G4coutDestination
//
#include "G4coutDestination.hh"
G4coutDestination::G4coutDestination()
{
}
G4coutDestination::~G4coutDestination()
{
}
G4int G4coutDestination::ReceiveG4cout(G4String)
{
return 0;
}
G4int G4coutDestination::ReceiveG4cerr(G4String)
{
return 0;
}
+1 -1
View File
@@ -22,7 +22,7 @@
//
//
// $Id: G4ios.cc,v 1.8 2004/06/11 14:18:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// GEANT4 tag $Name: geant4-07-01 $
//
//
// --------------------------------------------------------------