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,151 @@
// 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: G4Allocator.hh,v 2.4 1998/07/14 07:07:53 kurasige Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, CN Division, ASD group
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// ---------------- G4Allocator ----------------
// by Tim Bell, September 1995
// ------------------------------------------------------------
// SG, HPW: Protection vs double deletion of the same element, June 97.
#ifndef G4Allocator_h
#define G4Allocator_h 1
#include <stdlib.h>
#include <stddef.h>
// G4AllocatorPage
#include "G4AllocatorPage.hh"
template <class Type>
class G4Allocator
{
G4AllocatorPage<Type> *fPages;
G4AllocatorUnit<Type> *fFreeList;
private:
void AddNewPage();
Type *AddNewElement();
enum { Allocated = 0x47416C, Deleted = 0xB8BE93 };
public:
G4Allocator();
~G4Allocator();
inline Type *MallocSingle()
{
Type *anElement;
if (fFreeList != NULL)
{
fFreeList->deleted = Allocated;
anElement = &fFreeList->fElement;
fFreeList = fFreeList->fNext;
}
else
anElement = AddNewElement();
return anElement;
}
inline void FreeSingle(Type *anElement)
{
G4AllocatorUnit<Type> *fUnit;
fUnit = (G4AllocatorUnit<Type> *)
((char *) anElement -
offsetof(G4AllocatorUnit<Type>, fElement));
if (fUnit->deleted == Allocated) {
fUnit->deleted = Deleted;
fUnit->fNext = fFreeList;
fFreeList = fUnit;
} else if (fUnit->deleted == Deleted) {
// cerr << "G4Allocator : This object is already deleted" << endl;
} else {
// cerr << "G4Allocator: This object is allocated not by G4Allocator"<< endl;
}
}
};
template <class Type>
G4Allocator<Type>::G4Allocator()
{
fPages = NULL;
fFreeList = NULL;
AddNewPage();
return;
}
template <class Type>
G4Allocator<Type>::~G4Allocator()
{
G4AllocatorPage<Type> *aPage;
G4AllocatorPage<Type> *aNextPage;
aPage = fPages;
while (aPage != NULL)
{
aNextPage = aPage->fNext;
free(aPage->fUnits);
free(aPage);
aPage = aNextPage;
}
fPages = NULL;
fFreeList = NULL;
return;
}
static const G4int G4AllocatorPageSize = 1024;
template <class Type>
void G4Allocator<Type>::AddNewPage()
{
G4AllocatorPage<Type> *aPage;
register int unit_no;
aPage = new G4AllocatorPage<Type>;
aPage->fNext = fPages;
aPage->fUnits = (G4AllocatorUnit<Type> *)
malloc(G4AllocatorPageSize);
fPages = aPage;
for (unit_no = 0;
unit_no < (G4AllocatorPageSize /
sizeof(G4AllocatorUnit<Type>)-1);
++unit_no)
{
aPage->fUnits[unit_no].fNext = &aPage->fUnits[unit_no + 1];
}
aPage->fUnits[unit_no].fNext = fFreeList;
fFreeList = &aPage->fUnits[0];
}
template <class Type>
Type *G4Allocator<Type>::AddNewElement()
{
Type *anElement;
AddNewPage();
fFreeList->deleted = Allocated;
anElement = &fFreeList->fElement;
fFreeList=fFreeList->fNext;
return anElement;
}
#endif
@@ -0,0 +1,37 @@
// 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: G4AllocatorPage.hh,v 2.0 1998/07/02 17:32:37 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, CN Division, ASD group
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// -------------- G4AllocatorPage ----------------
// by Tim Bell, September 1995
// ------------------------------------------------------------
#ifndef G4AllocatorPage_h
#define G4AllocatorPage_h 1
//G4AllocatorUnit
#include "G4AllocatorUnit.hh"
template <class Type>
class G4AllocatorPage
{
public:
G4AllocatorPage<Type> *fNext;
G4AllocatorUnit<Type> *fUnits;
};
#endif
@@ -0,0 +1,37 @@
// 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: G4AllocatorUnit.hh,v 2.0 1998/07/02 17:32:38 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, CN Division, ASD group
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// -------------- G4AllocatorUnit ----------------
// by Tim Bell, September 1995
// ------------------------------------------------------------
#ifndef G4AllocatorUnit_h
#define G4AllocatorUnit_h 1
#include "globals.hh"
template <class Type>
class G4AllocatorUnit
{
public:
int deleted;
G4AllocatorUnit<Type> *fNext;
Type fElement;
};
#endif
@@ -0,0 +1,29 @@
// 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: G4DataVector.hh,v 2.1 1998/07/13 16:55:43 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, IT Division, ASD group
//
// ------------------------------------------------------------
#ifndef G4DataVector_h
#define G4DataVector_h 1
#include "globals.hh"
#include "G4ios.hh"
#include <rw/tvordvec.h>
typedef RWTValOrderedVector<G4double> G4DataVector;
#endif
@@ -0,0 +1,76 @@
// 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: G4FastVector.hh,v 2.2 1998/10/17 12:44:30 kurasige Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, CN Division, ASD group
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// ------------------------------------------------------------
#ifndef G4FastVector_h
#define G4FastVector_h 1
#include "globals.hh"
#include "G4ios.hh"
template <class Type, G4int N>
class G4FastVector
{
// Template class defining a vector of pointers,
// not performing boundary checking.
public:
G4FastVector() { ptr = &theArray[0]; }
~G4FastVector()
{
if (ptr != &theArray[0]) delete [] ptr;
}
inline Type* operator[](G4int anIndex) const
// Access operator to the array.
{
return ptr[anIndex];
}
void Initialize(G4int items)
// Normally the pointer ptr points to the stack-array
// theArray; only when the number of items is greater
// than N, memory is allocated dynamically.
{
if (ptr != &theArray[0])
delete [] ptr;
if (items > N)
ptr = new Type*[items];
else
ptr = &theArray[0];
}
inline void SetElement(G4int anIndex, Type *anElement)
// To insert an element at the given position inside
// the vector.
{
ptr[anIndex] = anElement;
}
private:
Type *theArray[N];
Type **ptr;
};
#endif
@@ -0,0 +1,158 @@
// 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.hh,v 2.2 1998/07/13 16:55:45 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------------
//
// Class G4LPhysicsFreeVector -- header file
//
// Derived from base class G4PhysicsVector
// This is a free vector for Low Energy Physics cross section data.
// The class name includes an "L" to distinguish it from other groups
// who may wish to implement a free vector in a different way.
// A subdivision method is used to find the energy|momentum bin.
//
// F.W. Jones, TRIUMF, 04-JUN-96
//
// 10-JUL-96 FWJ: adapted to changes in G4PhysicsVector.
//
// 27-MAR-97 FWJ: first version for Alpha release
// 20-JUN-97 FWJ: added comment re GetValue(): no longer virtual
//
#ifndef G4LPhysicsFreeVector_h
#define G4LPhysicsFreeVector_h 1
#include "G4PhysicsVector.hh"
class G4LPhysicsFreeVector : public G4PhysicsVector
{
public:
G4LPhysicsFreeVector();
G4LPhysicsFreeVector(size_t nbin, G4double binmin, G4double binmax);
~G4LPhysicsFreeVector();
// G4PhysicsVector has PutValue() but it is inconvenient.
// Want to simultaneously fill the bin and data vectors.
inline
void PutValues(size_t binNumber, G4double binValue, G4double dataValue)
{
binVector(binNumber) = binValue;
dataVector(binNumber) = dataValue;
}
// Note that theEnergy could be energy, momentum, or whatever.
inline
G4double GetValue(G4double theEnergy, G4bool& isOutRange);
inline
void SetVerboseLevel(G4int value)
{
verboseLevel = value;
}
inline
G4int GetVerboseLevel(G4int)
{
return verboseLevel;
}
inline
G4double GetLastEnergy()
{
return lastEnergy;
}
inline
size_t GetLastBin()
{
return lastBin;
}
void DumpValues();
private:
G4int verboseLevel;
// Pure virtual in G4PhysicsVector
inline
size_t FindBinLocation(G4double theEnergy) const;
};
// Note: GetValue() is no longer virtual in the parent class
// G4PhysicsVector, so at present the following function cannot
// be called through a base class pointer.
inline
G4double
G4LPhysicsFreeVector::GetValue(G4double theEnergy, G4bool& isOutRange)
{
G4double returnValue;
// verboseLevel = 2;
if (theEnergy < edgeMin) {
isOutRange = true;
if (verboseLevel > 1) G4cout << "G4LPhysicsFreeVector::GetValue " <<
theEnergy << " " << dataVector(0) << " " << isOutRange << endl;
returnValue = dataVector(0);
}
else if (theEnergy > edgeMax) {
isOutRange = true;
if (verboseLevel > 1) G4cout << "G4LPhysicsFreeVector::GetValue " <<
theEnergy << " " << dataVector(numberOfBin - 1) << " " <<
isOutRange << endl;
returnValue = dataVector(numberOfBin - 1);
}
else {
isOutRange = false;
G4int n = FindBinLocation(theEnergy);
G4double dsde = (dataVector(n + 1) - dataVector(n))/
(binVector(n + 1) - binVector(n));
if (verboseLevel > 1) G4cout << "G4LPhysicsFreeVector::GetValue " <<
theEnergy << " " << dataVector(n) + (theEnergy - binVector(n))*dsde <<
" " << isOutRange << endl;
returnValue = dataVector(n) + (theEnergy - binVector(n))*dsde;
}
return returnValue;
}
inline
size_t
G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
while (n1 != n3 - 1) {
if (theEnergy > binVector(n2))
n1 = n2;
else
n3 = n2;
n2 = n1 + (n3 - n1 + 1)/2;
}
if (verboseLevel > 1) G4cout <<
"G4LPhysicsFreeVector::FindBinLocation: returning " << n1 << endl;
return (size_t)n1;
}
#endif
@@ -0,0 +1,47 @@
// 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: G4OrderedTable.hh,v 2.0 1998/07/02 17:32:46 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
//
// This class is setting up an ordered collection of
// ordered vectors of <G4double>
// 30 September 1996, M.Maire
//
// ------------------------------------------------------------
#ifndef G4OrderedTable_h
#define G4OrderedTable_h 1
#include "globals.hh"
#include <rw/tvordvec.h>
#include <rw/tpordvec.h>
class G4ValVector : public RWTValOrderedVector<G4double>
{
public:
G4ValVector(size_t capac=RWDEFAULT_CAPACITY)
: RWTValOrderedVector<G4double>(capac) {;}
virtual ~G4ValVector() {;}
G4bool operator==(const G4ValVector &right) const
{
return (this == (G4ValVector *) &right);
}
};
typedef RWTPtrOrderedVector<G4ValVector> G4OrderedTable;
#endif
@@ -0,0 +1,117 @@
// 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.hh,v 2.1 1998/07/12 02:58:55 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//--------------------------------------------------------------------
// GEANT 4 class header file
//
// G4PhysicsFreeVector.hh
//
// Description:
// A physics vector which has values of energy-loss, cross-section,
// and other physics values of a particle in matter in a given
// range of the energy, momentum, etc. The scale of energy/momentum
// bins is in free, ie. it is NOT need to be linear or log. Only
// restrication is that bin values alway have to increase from
// a lower bin to a higher bin. This is necessary for the binary
// search to work correctly.
//
// History:
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
// 06 Jun. 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.
//
//--------------------------------------------------------------------
#ifndef G4PhysicsFreeVector_h
#define G4PhysicsFreeVector_h 1
#include "globals.hh"
#include "G4DataVector.hh"
#include "G4PhysicsVector.hh"
class G4PhysicsFreeVector : public G4PhysicsVector
{
public:
// Constructors
G4PhysicsFreeVector();
G4PhysicsFreeVector(size_t theNbin);
G4PhysicsFreeVector(const G4DataVector& binVector,
const G4DataVector& dataVector);
// 'binVector' has the low edge value of each scale bin.
// 'dataVector' has the cross-section/energy-loss/etc at
// the energy/momenturm of the corresponding a bin of
// 'binVector'. 'binVector' and 'dataVector' need to have
// the same vector length.
// Destructor
~G4PhysicsFreeVector();
// Special PutValue function for PhyiscsFreeVector
void PutValue( size_t binNumber, G4double binValue,
G4double dataValue );
// To use this method to fill a PhyiscsFreeVector, you have
// to Construct a PhysicsFreeVector of the size you need
// using G4PhysicsFreeVector(size_t theNbin). Also take
// note that you have to fill all bin values and data
// values before you the PhysicsFreeVector.
protected:
size_t FindBinLocation(G4double theEnergy) const;
// Find bin# in which theEnergy belongs - virtual function
};
inline size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const {
// For G4PhysicsFreeVector, FindBinLocation is implemented using
// the binary search algorithm.
//
// Because this is a virtual function, it is accessed through a
// pointer to the G4PhyiscsVector object for most usages. In this
// case, 'inline' will not be invoked. However, there is a possibility
// that the user access to the G4PhysicsFreeVector object directly and
// not through pointers or references. In this case, the 'inline' will
// be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
size_t lowerBound = 0;
size_t upperBound = numberOfBin-1;
do {
size_t midBin = (lowerBound + upperBound)/2;
if( theEnergy < binVector(midBin) )
upperBound = midBin-1;
else
lowerBound = midBin+1;
} while (lowerBound <= upperBound);
return upperBound;
}
#endif
@@ -0,0 +1,93 @@
// 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.hh,v 2.0 1998/07/02 17:32:50 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//--------------------------------------------------------------------
// GEANT 4 class header file
//
// G4PhysicsLinearVector.hh
//
// Description:
// A physics vector which has values of energy-loss, cross-section,
// and other physics values of a particle in matter in a given
// range of the energy, momentum, etc. The scale of energy/momentum
// bins is in linear.
//
// 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 : Cache mechanism and hidden bin from the
// user introduced.
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added.
//
//--------------------------------------------------------------------
#ifndef G4PhysicsLinearVector_h
#define G4PhysicsLinearVector_h 1
#include "globals.hh"
#include "G4DataVector.hh"
#include "G4PhysicsVector.hh"
class G4PhysicsLinearVector : public G4PhysicsVector
{
public:
// Constructors
G4PhysicsLinearVector();
G4PhysicsLinearVector(size_t theNbin);
G4PhysicsLinearVector(G4double theEmin, G4double theEmax, size_t theNbin);
// Destructor
~G4PhysicsLinearVector();
protected:
size_t FindBinLocation(G4double theEnergy) const;
// Find bin# in which theEnergy belongs - pure virtual function
private:
G4double dBin; // Bin width - useful only for fixed binning
G4double baseBin; // Set this in constructor to gain performance
};
inline size_t G4PhysicsLinearVector::FindBinLocation(G4double theEnergy) const {
// For G4PhysicsLinearVector, FindBinLocation is implemented using
// a simple arithmetic calculation.
//
// Because this is a virtual function, it is accessed through a
// pointer to the G4PhyiscsVector object for most usages. In this
// case, 'inline' will not be invoked. However, there is a possibility
// that the user access to the G4PhysicsLinearVector object directly and
// not through pointers or references. In this case, the 'inline' will
// be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
return size_t( theEnergy/dBin - baseBin );
}
#endif
@@ -0,0 +1,96 @@
// 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.hh,v 2.0 1998/07/02 17:32:54 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//--------------------------------------------------------------------
// GEANT 4 class header file
//
// G4PhysicsLogVector.hh
//
// Description:
// A physics vector which has values of energy-loss, cross-section,
// and other physics values of a particle in matter in a given
// range of the energy, momentum, etc. The scale of energy/momentum
// bins is in logarithmic.
//
// History:
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
// 03 Mar. 1996, K.Amako : Implemented the 1st version
// 27 Apr. 1996, K.Amako : Cache mechanism added
// 01 Jul. 1996, K.Amako : Hidden bin from the user introduced
// 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added.
//
//--------------------------------------------------------------------
#ifndef G4PhysicsLogVector_h
#define G4PhysicsLogVector_h 1
#include "globals.hh"
#include "G4DataVector.hh"
#include "G4PhysicsVector.hh"
class G4PhysicsLogVector : public G4PhysicsVector
{
public:
// Constructors
G4PhysicsLogVector();
G4PhysicsLogVector(size_t theNbin);
G4PhysicsLogVector(G4double theEmin, G4double theEmax, size_t theNbin);
// Because of logarithmic scale, note that 'theEmin' has to be
// greater than zero. No protection exists against this error.
// Destructor
~G4PhysicsLogVector();
protected:
size_t FindBinLocation(G4double theEnergy) const;
// Find bin# in which theEnergy belongs - pure virtual function
private:
G4double dBin; // Bin width - useful only for fixed binning
G4double baseBin; // Set this in constructor for performance
};
inline size_t G4PhysicsLogVector::FindBinLocation(G4double theEnergy) const {
// For G4PhysicsLogVector, FindBinLocation is implemented using
// a simple arithmetic calculation.
//
// Because this is a virtual function, it is accessed through a
// pointer to the G4PhyiscsVector object for most usages. In this
// case, 'inline' will not be invoked. However, there is a possibility
// that the user access to the G4PhysicsLogVector object directly and
// not through pointers or references. In this case, the 'inline' will
// be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
return size_t( log10(theEnergy)/dBin - baseBin );
}
#endif
@@ -0,0 +1,145 @@
// 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.hh,v 2.2 1998/07/13 16:55:48 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Definition
////////////////////////////////////////////////////////////////////////
//
// File: G4PhysicsOrderedFreeVector.hh
// Version: 1.0
// Created: 1996-08-13
// Author: Juliet Armstrong
// Updated: 1997-03-25 by Peter Gumplinger
// > cosmetics (only)
// mail: gum@triumf.ca
//
// Description:
// A physics ordered free vector inherits from G4PhysicsVector which
// has values of energy-loss, cross-section, and other physics values
// of a particle in matter in a given range of the energy, momentum,
// etc.). In addition, the ordered free vector provides a method for
// the user to insert energy/value pairs in sequence. Methods to
// Retrieve the Max and Min energies and values from the vector are
// also provided.
//
////////////////////////////////////////////////////////////////////////
#ifndef G4PhysicsOrderedFreeVector_h
#define G4PhysicsOrderedFreeVector_h 1
/////////////
// Includes
/////////////
#include <rw/tpordvec.h>
#include "G4PhysicsVector.hh"
/////////////////////
// Class Definition
/////////////////////
class G4PhysicsOrderedFreeVector : public G4PhysicsVector
{
public:
////////////////////////////////
// Constructors and Destructor
////////////////////////////////
G4PhysicsOrderedFreeVector();
G4PhysicsOrderedFreeVector(G4double* Energies,
G4double* Values,
size_t VectorLength);
~G4PhysicsOrderedFreeVector();
////////////
// Methods
////////////
void InsertValues(G4double energy, G4double value);
G4double GetLowEdgeEnergy(size_t binNumber) const;
G4double GetMaxValue();
G4double GetMinValue();
G4double GetEnergy(G4double aValue);
G4double GetMaxLowEdgeEnergy();
G4double GetMinLowEdgeEnergy();
void DumpValues();
private:
size_t FindBinLocation(G4double theEnergy) const;
size_t FindValueBinLocation(G4double aValue);
G4double LinearInterpolationOfEnergy(G4double aValue, size_t theLocBin);
};
////////////////////
// Inline methods
////////////////////
inline
G4double G4PhysicsOrderedFreeVector::GetMaxValue()
{
return dataVector.last();
}
inline
G4double G4PhysicsOrderedFreeVector::GetMinValue()
{
return dataVector.first();
}
inline
G4double G4PhysicsOrderedFreeVector::GetMaxLowEdgeEnergy()
{
return binVector.last();
}
inline
G4double G4PhysicsOrderedFreeVector::GetMinLowEdgeEnergy()
{
return binVector.first();
}
inline
void G4PhysicsOrderedFreeVector::DumpValues()
{
for (G4int i = 0; i < numberOfBin; i++) {
G4cout << binVector[i] << "\t" << dataVector[i] << endl;
}
}
inline
size_t G4PhysicsOrderedFreeVector::FindBinLocation(G4double theEnergy) const
{
G4int n1 = 0;
G4int n2 = numberOfBin/2;
G4int n3 = numberOfBin - 1;
while (n1 != n3 - 1) {
if (theEnergy > binVector(n2))
n1 = n2;
else
n3 = n2;
n2 = n1 + (n3 - n1 + 1)/2;
}
return (size_t)n1;
}
#endif /* G4PhysicsOrderedFreeVector_h */
@@ -0,0 +1,32 @@
// 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: G4PhysicsTable.hh,v 2.0 1998/07/02 17:32:58 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
//
// Modified 01 March 1996, K. Amako
// ------------------------------------------------------------
#ifndef G4PhysicsTable_h
#define G4PhysicsTable_h 1
#include <rw/tpordvec.h>
#include "globals.hh"
#include "G4PhysicsVector.hh"
typedef RWTPtrOrderedVector<G4PhysicsVector> G4PhysicsTable;
#endif
@@ -0,0 +1,224 @@
// 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.hh,v 2.1 1998/07/12 02:58:57 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//---------------------------------------------------------------
// GEANT 4 class header file
//
// G4PhysicsVector.hh
//
// Description:
// A physics vector which has values of energy-loss, cross-section,
// and other physics values of a particle in matter in a given
// range of the energy, momentum, etc.
// This class serves as the base class for a vector having various
// energy scale, for example like 'log', 'linear', 'free', etc.
//
// History:
// 02 Dec. 1995, G.Cosmo : Structure created based on object model
// 03 Mar. 1996, K.Amako : Implemented the 1st version
// 27 Apr. 1996, K.Amako : Cache mechanism added
// 01 Jul. 1996, K.Amako : Now GetValue not virtual.
// 21 Sep. 1996, K.Amako : Added [] and () operators.
//
//---------------------------------------------------------------
#ifndef G4PhysicsVector_h
#define G4PhysicsVector_h 1
#include "globals.hh"
#include "G4DataVector.hh"
#include <rw/tpordvec.h>
class G4PhysicsVector
{
public:
// Constructor and destructor
G4PhysicsVector(){};
virtual ~G4PhysicsVector(){};
// Public functions
G4double GetValue(G4double theEnergy, G4bool& isOutRange);
// Get the crosssection/energy-loss value corresponding to the
// given energy. An appropriate interpolation is used to calculate
// the value.
// [Note] isOutRange is not used anymore. This argument is kept
// for the compatibility reason.
// Public operators
G4int operator==(const G4PhysicsVector &right) const ;
G4int operator!=(const G4PhysicsVector &right) const ;
G4double operator[](const size_t binNumber) const ;
// Returns simply the value in the bin specified by 'binNumber'
// of the dataVector. The boundary check will be Done. If you
// don't want this check, use the operator ().
G4double operator()(const size_t binNumber) const ;
// Returns simply the value in the bin specified by 'binNumber'
// of the dataVector. The boundary check will not be Done. If
// you want this check, use the operator [].
// Public functions
void PutValue(size_t binNumber, G4double theValue);
// Put 'theValue' into the bin specified by 'binNumber'.
// Take note that the 'binNumber' starts from '0'.
// To fill the vector, you have beforehand to Construct a vector
// by the constructor with Emin, Emax, Nbin. 'theValue' should
// be the crosssection/energyloss value corresponding to the low
// edge energy of the bin specified by 'binNumber'. You can get
// the low edge energy value of a bin by GetLowEdgeEnergy().
virtual G4double GetLowEdgeEnergy(size_t binNumber) const;
// Get the energy value at the low edge of the specified bin.
// Take note that the 'binNumber' starts from '0'.
// This value is defined when a physics vector is constructed
// by a constructor of a derived class. Use this function
// when you fill physis vector by PutValue().
size_t GetVectorLength() const;
// Get the toal length (bin number) of the vector.
G4bool IsFilledVectorExist() const;
// Is non-empty physics vector already exist?
void LinkPhysicsTable(RWTPtrOrderedVector<G4PhysicsVector>& theTable);
// Link the given G4PhysicsTable to the current G4PhyiscsVector.
G4bool IsLinkedTableExist() const;
// Has this physics vector an extended physics table?
const RWTPtrOrderedVector<G4PhysicsVector>* GetNextTable() const;
// Returns the pointer to a physics table created for elements
// or isotopes (when the cross-sesctions or energy-losses
// depend explicitly on them).
void PutComment(const G4String& theComment);
// Put a comment to the G4PhysicsVector. This may help to check
// whether your are accessing to the one you want.
G4String GetComment() const;
// Retrieve the comment of the G4PhysicsVector.
protected:
G4double edgeMin; // Lower edge value of the lowest bin
G4double edgeMax; // Lower edge value of the highest bin
size_t numberOfBin;
G4double lastEnergy; // Cache the last input value
G4double lastValue; // Cache the last output value
size_t lastBin; // Cache the last bin location
G4DataVector dataVector; // Vector to keep the crossection/energyloss
G4DataVector binVector; // Vector to keep the low edge value of bin
RWTPtrOrderedVector<G4PhysicsVector>* ptrNextTable;
// Link to the connected physics table
G4double LinearInterpolation(G4double theEnergy, size_t theLocBin);
// Linear interpolation function
virtual size_t FindBinLocation(G4double theEnergy) const=0;
// Find the bin# in which theEnergy belongs - pure virtual function
private:
G4String comment;
};
inline G4double G4PhysicsVector::operator[](const size_t binNumber) const
{
return dataVector[binNumber];
}
inline G4double G4PhysicsVector::operator()(const size_t binNumber) const
{
return dataVector(binNumber);
}
inline const RWTPtrOrderedVector<G4PhysicsVector>*
G4PhysicsVector::GetNextTable() const
{
return ptrNextTable;
}
inline G4double G4PhysicsVector::LinearInterpolation(G4double theEnergy,
size_t theLocBin) {
// Linear interpolation is used to get the value. If the give energy
// is in the highest bin, no interpolation will be Done. Because
// there is an extra bin hidden from a user at locBin=numberOfBin,
// the following interpolation is valid even the current locBin=
// numberOfBin-1.
G4double intplFactor = (theEnergy-binVector(theLocBin))
/ (binVector(theLocBin+1)-binVector(theLocBin)); // Interpolation factor
return dataVector(theLocBin) +
( dataVector(theLocBin+1)-dataVector(theLocBin) ) * intplFactor;
}
inline G4double G4PhysicsVector::GetValue(G4double theEnergy,
G4bool& isOutRange) {
// Use cache for speed up - check if the value 'theEnergy' is same as the
// last call. If it is same, then use the last bin location. Also the
// value 'theEnergy' lies between the last energy and low edge of of the
// bin of last call, then the last bin location is used.
isOutRange = false; // No range check.
size_t locBin;
if( theEnergy == lastEnergy ) {
return lastValue;
}
else if( (theEnergy < lastEnergy) &&
(theEnergy >= binVector(lastBin)) ) {
locBin = lastBin;
lastEnergy = theEnergy;
lastValue = LinearInterpolation(theEnergy, locBin);
return lastValue;
}
else if( theEnergy < edgeMin ){
lastBin = 0;
lastEnergy = theEnergy;
lastValue = dataVector(0);
return lastValue;
}
else if( theEnergy >= edgeMax ){
lastBin = numberOfBin-1;
lastEnergy = theEnergy;
lastValue = dataVector( numberOfBin-1 );
return lastValue;
}
else {
locBin = FindBinLocation(theEnergy);
lastBin = locBin;
lastEnergy = theEnergy;
lastValue = LinearInterpolation(theEnergy, locBin);
return lastValue;
}
}
#endif
@@ -0,0 +1,27 @@
// 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: G4RotationMatrix.hh,v 2.0 1998/07/02 17:33:01 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ----------------------------------------------------------------------
//
// G4RotationMatrix class, typedef to CLHEP HepRotation
//
// ----------------------------------------------------------------------
#ifndef G4ROTATIONMATRIX_HH
#define G4ROTATIONMATRIX_HH
#include "globals.hh"
#include "G4ThreeVector.hh"
#include <CLHEP/Vector/Rotation.h>
typedef HepRotation G4RotationMatrix;
#endif
@@ -0,0 +1,26 @@
// 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: G4ThreeVector.hh,v 2.0 1998/07/02 17:33:03 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ----------------------------------------------------------------------
//
// G4ThreeVector class, typedef to CLHEP Hep3Vector
//
// ----------------------------------------------------------------------
#ifndef G4THREEVECTOR_HH
#define G4THREEVECTOR_HH
#include "globals.hh"
#include <CLHEP/Vector/ThreeVector.h>
typedef Hep3Vector G4ThreeVector;
#endif
+128
View File
@@ -0,0 +1,128 @@
// 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.hh,v 2.2 1998/07/17 08:51:44 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ----------------------------------------------------------------------
// class G4Timer
//
// Class for timer objects, able to measure elasped user/system process
// time.
//
// Note: Uses <sys/times.h> & <unistd.h> - POSIX.1 defined
//
// Member functions:
//
// G4Timer()
// Construct a timer object
// Start()
// Start timing
// Stop()
// Stop timing
// G4bool IsValid()
// Return true if have a valid time (ie start() and stop() called)
// G4double GetRealElapsed()
// Return the elapsed real time between last calling start() and stop()
// G4double GetSystemElapsed()
// Return the elapsed system time between last calling start() and stop()
// G4double GetUserElapsed()
// Return the elapsed user time between last calling start() and stop()
//
// Operators:
//
// ostream& operator << (ostream& os, const G4Timer& t);
// Print the elapsed real,system and usertimes on os. Prints **s for times
// if !IsValid
//
// Member data:
//
// G4bool fValidTimes
// True after start and stop have both been called more than once and
// an equal number of times
// clock_t fStartRealTime,fEndRealTime
// Real times (arbitrary time 0)
// tms fStartTimes,fEndTimes
// Timing structures (see times(2)) for start and end times
//
// History:
// 23.08.96 P.Kent Updated to also computed real elapsed time
// 21.08.95 P.Kent
// 29.04.97 G.Cosmo Added timings for Windows/NT
#ifndef G4TIMER_HH
#define G4TIMER_HH
#ifndef WIN32
# include <unistd.h>
# include <sys/times.h>
#else
# include <time.h>
# define _SC_CLK_TCK 1
extern "C" {
int sysconf(int);
};
// Structure returned by times()
struct tms {
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time, children */
clock_t tms_cstime; /* system time, children */
};
extern "C" {
extern clock_t times(struct tms *);
};
#endif /* WIN32 */
#include "globals.hh"
class ostream;
class G4Timer
{
public:
G4Timer() : fValidTimes(false) {;}
inline void Start();
inline void Stop();
inline G4bool IsValid() const;
G4double GetRealElapsed() const;
G4double GetSystemElapsed() const;
G4double GetUserElapsed() const;
private:
G4bool fValidTimes;
clock_t fStartRealTime,fEndRealTime;
tms fStartTimes,fEndTimes;
};
ostream& operator << (ostream& os, const G4Timer& t);
// Inline functions:
inline void G4Timer::Start()
{
fValidTimes=false;
fStartRealTime=times(&fStartTimes);
}
inline void G4Timer::Stop()
{
fEndRealTime=times(&fEndTimes);
fValidTimes=true;
}
inline G4bool G4Timer::IsValid() const
{
return fValidTimes;
}
#endif
@@ -0,0 +1,137 @@
// 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.hh,v 2.3 1998/12/02 09:50:21 asaim Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// -----------------------------------------------------------------
// GEANT 4 class header file
//
// For information related to this code contact:
// CERN, CN Division, ASD group
//
// ------------------- class G4UnitsTable -----------------
//
// 17-05-98: first version, M.Maire
// 13-10-98: Units and symbols printed in fxed length
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifndef G4UnitsTable_HH
#define G4UnitsTable_HH
#include "globals.hh"
#include <rw/tpordvec.h>
class G4UnitsCategory;
typedef RWTPtrOrderedVector<G4UnitsCategory> G4UnitsTable;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4UnitDefinition
{
public:
G4UnitDefinition(G4String name, G4String symbol,G4String category,
G4double value);
~G4UnitDefinition();
G4int operator==(const G4UnitDefinition&) const;
G4int operator!=(const G4UnitDefinition&) const;
private:
G4UnitDefinition(G4UnitDefinition&);
const G4UnitDefinition & operator=(const G4UnitDefinition&);
public:
G4String GetName() {return Name;};
G4String GetSymbol() {return SymbolName;};
G4double GetValue() {return Value;};
void PrintDefinition();
static void BuildUnitsTable();
static void PrintUnitsTable();
static
G4UnitsTable& GetUnitsTable() {return theUnitsTable;};
static G4double GetValueOf (G4String);
static G4String GetCategory(G4String);
private:
G4String Name; // SI name
G4String SymbolName; // SI symbol
G4double Value; // value in the internal system of units
static
G4UnitsTable theUnitsTable; // table of Units
size_t CategoryIndex; // category index of this unit
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
typedef RWTPtrOrderedVector<G4UnitDefinition> G4UnitsContainer;
class G4UnitsCategory
{
public:
G4UnitsCategory(G4String name);
~G4UnitsCategory();
G4int operator==(const G4UnitsCategory&) const;
G4int operator!=(const G4UnitsCategory&) const;
private:
G4UnitsCategory(G4UnitsCategory&);
const G4UnitsCategory & operator=(const G4UnitsCategory&);
public:
G4String GetName() {return Name;};
G4UnitsContainer& GetUnitsList() {return UnitsList;};
G4int GetNameMxLen() {return NameMxLen;};
G4int GetSymbMxLen() {return SymbMxLen;};
void UpdateNameMxLen(G4int len) {if (NameMxLen<len) NameMxLen=len;};
void UpdateSymbMxLen(G4int len) {if (SymbMxLen<len) SymbMxLen=len;};
void PrintCategory();
private:
G4String Name; // dimensional family: Length,Volume,Energy ...
G4UnitsContainer UnitsList; // List of units in this family
G4int NameMxLen; // max length of the units name
G4int SymbMxLen; // max length of the units symbol
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class G4BestUnit
{
public:
G4BestUnit(G4double,G4String);
~G4BestUnit();
public:
G4double GetValue() {return Value;};
G4String GetCategory() {return Category;};
size_t GetIndexOfCategory() {return IndexOfCategory;};
friend
ostream& operator<<(ostream&,G4BestUnit);
private:
G4double Value; // value in the internal system of units
G4String Category; // dimensional family: Length,Volume,Energy ...
size_t IndexOfCategory; // position of Category in UnitsTable
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#endif
@@ -0,0 +1,62 @@
// 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: G4UserLimits.hh,v 2.1 1998/07/12 02:58:59 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
// class G4UserLimits Simple placeholder for user Step limitations
// Paul Kent August 96
//
// 01-11-97: change GetMaxAllowedStep(), Hisaya Kurashige
// 08-04-98: new data members, mma
//
#ifndef G4USERLIMITS_HH
#define G4USERLIMITS_HH
#include "globals.hh"
class G4Track;
class G4UserLimits
{
public:
G4UserLimits(G4double ustepMax = DBL_MAX,
G4double utrakMax = DBL_MAX,
G4double utimeMax = DBL_MAX,
G4double uekinMin = 0.,
G4double urangMin = 0. );
virtual ~G4UserLimits();
public:
// If a Logical Volume has a G4UserLimits object,
//the Step length should be limited as shorter
//than MaxAllowedStep in the volume.
// In the current design, the others limits are irrelavant in tracking
virtual G4double GetMaxAllowedStep(const G4Track&);
virtual G4double GetUserMaxTrackLength(const G4Track&) ;
virtual G4double GetUserMaxTime (const G4Track&);
virtual G4double GetUserMinEkine(const G4Track&);
virtual G4double GetUserMinRange(const G4Track&);
virtual void SetMaxAllowedStep(G4double ustepMax);
virtual void SetUserMaxTrackLength(G4double utrakMax);
virtual void SetUserMaxTime(G4double utimeMax);
virtual void SetUserMinEkine(G4double uekinMin);
virtual void SetUserMinRange(G4double urangMin);
protected:
G4double fMaxStep; //max allowed Step size in this volume
G4double fMaxTrack; //max total track length
G4double fMaxTime; //max time
G4double fMinEkine; //min kinetic energy
G4double fMinRange; //min remaining range
};
#include "G4UserLimits.icc"
#endif
@@ -0,0 +1,82 @@
// 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: G4UserLimits.icc,v 2.0 1998/07/02 17:33:08 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
// class G4UserLimits inline implementation
//
// 01-11-97: change GetMaxAllowedStep(), Hisaya Kurashige
// 08-04-98: new data members, mma
//
#include "G4UserLimits.hh"
inline G4UserLimits::G4UserLimits(G4double ustepMax,
G4double utrakMax,
G4double utimeMax,
G4double uekinMin,
G4double urangMin)
:fMaxStep (ustepMax),fMaxTrack(utrakMax),fMaxTime(utimeMax),
fMinEkine(uekinMin),fMinRange(urangMin)
{}
inline G4UserLimits::~G4UserLimits(){}
// In this implementation, G4UserLimits has a single value
// for MaxAllowedStep.
inline G4double G4UserLimits::GetMaxAllowedStep(const G4Track&)
{
return fMaxStep;
}
inline G4double G4UserLimits::GetUserMaxTrackLength(const G4Track&)
{
return fMaxTrack;
}
inline G4double G4UserLimits::GetUserMaxTime(const G4Track&)
{
return fMaxTime;
}
inline G4double G4UserLimits::GetUserMinEkine(const G4Track&)
{
return fMinEkine;
}
inline G4double G4UserLimits::GetUserMinRange(const G4Track&)
{
return fMinRange;
}
inline void G4UserLimits::SetMaxAllowedStep(G4double ustepMax)
{
fMaxStep=ustepMax;
}
inline void G4UserLimits::SetUserMaxTrackLength(G4double utrakMax)
{
fMaxTrack=utrakMax;
}
inline void G4UserLimits::SetUserMaxTime(G4double utimeMax)
{
fMaxTime=utimeMax;
}
inline void G4UserLimits::SetUserMinEkine(G4double uekinMin)
{
fMinEkine=uekinMin;
}
inline void G4UserLimits::SetUserMinRange(G4double urangMin)
{
fMinRange=urangMin;
}
@@ -0,0 +1,13 @@
#ifndef G4COUTDESTINATION_HH
#define G4COUTDESTINATION_HH
#include "globals.hh"
class G4coutDestination
{
public:
virtual int ReceiveG4cout(G4String){return 0;}
virtual int ReceiveG4cerr(G4String){return 0;}
};
#endif
+24
View File
@@ -0,0 +1,24 @@
#ifndef included_G4ios
#define included_G4ios
#if defined(OO_DDL_TRANSLATION)
/*
* stdlib needs to be included before iostream.h
* during oddlx runs to work around a parser
* problem of AIX ooddlx v4.0.2 with some versions of
* AIX system header files.
*/
#include <stdlib.h>
#endif
#include <iostream.h>
#ifdef G4STREAM
extern ostream G4cout;
extern ostream G4cerr;
#else
#define G4cout cout
#define G4cerr cerr
#endif
#endif
@@ -0,0 +1,133 @@
#ifndef G4STRSTREAM_HH
#define G4STRSTREAM_HH
#include <iostream.h>
#ifdef WIN32
#include <Strstrea.h>
#else
#include <strstream.h>
#endif
#include "globals.hh"
#include "G4coutDestination.hh"
class G4strstreambuf;
extern G4strstreambuf G4coutbuf;
extern G4strstreambuf G4cerrbuf;
#ifndef G4STREAM_STREAMBUF_IMPLEMENTATION
class G4strstreambuf : public strstreambuf {
public:
G4strstreambuf() {
destination = NULL;
}
void SetDestination(G4coutDestination * value) {
destination = value;
}
int sync() {
G4String stringToSend;
int c;
int result;
result = EOF;
while (( c= sbumpc() ) != EOF) {
stringToSend += (char) c;
}
if(this == & G4coutbuf && destination != NULL) {
result = destination->ReceiveG4cout(stringToSend);
} else
if(this == & G4cerrbuf && destination != NULL) {
result = destination->ReceiveG4cerr(stringToSend);
} else
if(this == & G4coutbuf && destination == NULL) {
cout << stringToSend << flush;
result =0;
} else
if(this == & G4cerrbuf && destination == NULL) {
cerr << stringToSend << flush;
result =0;
}
return result;
};
private:
G4coutDestination *destination;
};
//
#else // G4STREAM_STREAMBUF_IMPLEMENTATION :
// On NT the upper implementation involves that
// first character is lost when sending to destination !
// Below implementation is correct on this platform.
class G4strstreambuf : public streambuf {
public:
G4strstreambuf() {
destination = NULL;
count = 0;
size = 127;
buffer = new char[size+1];
}
~G4strstreambuf() {
delete buffer;
}
void SetDestination(G4coutDestination * value) {
destination = value;
}
int overflow(int c=EOF) {
int result = 0;
if(count>=size) {
buffer[count] = '\0';
count = 0;
result = ReceiveString ();
}
buffer[count] = c;
count++;
if(c=='\n') {
buffer[count] = '\0';
count = 0;
result = ReceiveString ();
}
return result;
}
int sync() {
buffer[count] = '\0';
count = 0;
return ReceiveString ();
}
#ifdef WIN32
int underflow() {
return 0;
}
#endif
int ReceiveString () {
G4String stringToSend = buffer;
int result;
if(this == & G4coutbuf && destination != NULL) {
result = destination->ReceiveG4cout(stringToSend);
} else if(this == & G4cerrbuf && destination != NULL) {
result = destination->ReceiveG4cerr(stringToSend);
} else if(this == & G4coutbuf && destination == NULL) {
cout << stringToSend << flush;
result =0;
} else if(this == & G4cerrbuf && destination == NULL) {
cerr << stringToSend << flush;
result =0;
}
return result;
};
private:
G4coutDestination * destination;
char* buffer;
int count,size;
};
#endif // G4STREAM_STREAMBUF_IMPLEMENTATION :
#endif
@@ -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: PhysicalConstants.h,v 2.1 1998/07/12 02:58:59 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// -*- C++ -*-
//
// ----------------------------------------------------------------------
// HEP coherent Physical Constants
//
// This file has been provided by Geant4 (simulation toolkit for HEP).
//
// The basic units are :
// millimeter
// nanosecond
// Mega electron Volt
// positon charge
// degree Kelvin
// amount of substance (mole)
// luminous intensity (candela)
// radian
// steradian
//
// Below is a non exhaustive List of Physical CONSTANTS,
// computed in the Internal HEP System Of Units.
//
// Most of them are extracted from the Particle Data Book :
// Phys. Rev. D volume 50 3-1 (1994) page 1233
//
// ...with a meaningful (?) name ...
//
// You can add your own constants.
//
// Author: M.Maire
//
// History:
//
// 23.02.96 Created
// 26.03.96 Added constants for standard conditions of temperature
// and pressure; also added Gas threshold.
#ifndef HEP_PHYSICAL_CONSTANTS_H
#define HEP_PHYSICAL_CONSTANTS_H
#include "SystemOfUnits.h"
//
//
//
static const HepDouble pi = 3.14159265358979323846;
static const HepDouble twopi = 2*pi;
static const HepDouble halfpi = pi/2;
static const HepDouble pi2 = pi*pi;
//
//
//
static const HepDouble Avogadro = 6.0221367e+23/mole;
//
// c = 299.792458 mm/ns
// c^2 = 898.7404 (mm/ns)^2
//
static const HepDouble c_light = 2.99792458e+8 * m/s;
static const HepDouble c_squared = c_light * c_light;
//
// h = 4.13566e-12 MeV*ns
// hbar = 6.58212e-13 MeV*ns
// hbarc = 197.32705e-12 MeV*mm
//
static const HepDouble h_Planck = 6.6260755e-34 * joule*s;
static const HepDouble hbar_Planck = h_Planck/twopi;
static const HepDouble hbarc = hbar_Planck * c_light;
static const HepDouble hbarc_squared = hbarc * hbarc;
//
//
//
static const HepDouble electron_charge = - eplus; // see SystemOfUnits.h
static const HepDouble e_squared = eplus * eplus;
//
// amu_c2 - atomic equivalent mass unit
// amu - atomic mass unit
//
static const HepDouble electron_mass_c2 = 0.51099906 * MeV;
static const HepDouble proton_mass_c2 = 938.27231 * MeV;
static const HepDouble neutron_mass_c2 = 939.56563 * MeV;
static const HepDouble amu_c2 = 931.49432 * MeV;
static const HepDouble amu = amu_c2/c_squared;
//
// permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm
// permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm)
//
static const HepDouble mu0 = 4*pi*1.e-7 * henry/m;
static const HepDouble epsilon0 = 1./(c_squared*mu0);
//
// electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2)
//
static const HepDouble elm_coupling = e_squared/(4*pi*epsilon0);
static const HepDouble fine_structure_const = elm_coupling/hbarc;
static const HepDouble classic_electr_radius = elm_coupling/electron_mass_c2;
static const HepDouble electron_Compton_length = hbarc/electron_mass_c2;
static const HepDouble Bohr_radius = electron_Compton_length/fine_structure_const;
static const HepDouble alpha_rcl2 = fine_structure_const
*classic_electr_radius
*classic_electr_radius;
static const HepDouble twopi_mc2_rcl2 = twopi*electron_mass_c2
*classic_electr_radius
*classic_electr_radius;
//
//
//
static const HepDouble k_Boltzmann = 8.617385e-11 * MeV/kelvin;
//
//
//
static const HepDouble STP_Temperature = 273.15*kelvin;
static const HepDouble STP_Pressure = 1.*atmosphere;
static const HepDouble kGasThreshold = 10.*mg/cm3;
//
//
//
static const HepDouble universe_mean_density = 1.e-25*g/cm3;
#endif /* HEP_PHYSICAL_CONSTANTS_H */
@@ -0,0 +1,282 @@
// 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: SystemOfUnits.h,v 2.4 1998/09/01 10:45:38 maire Exp $
// GEANT4 tag $Name: geant4-00 $
//
// -*- C++ -*-
//
// ----------------------------------------------------------------------
// HEP coherent system of Units
//
// This file has been provided by Geant4 (simulation toolkit for HEP).
//
// The basic units are :
// millimeter (millimeter)
// nanosecond (nanosecond)
// Mega electron Volt (MeV)
// positron charge (eplus)
// degree Kelvin (kelvin)
// the amount of substance (mole)
// luminous intensity (candela)
// radian (radian)
// steradian (steradian)
//
// Below is a non exhaustive List of derived and pratical units
// (i.e. mostly the SI units).
// You can add your own units.
//
// The SI numerical value of the positron charge is defined here,
// as it is needed for conversion factor : positron charge = e_SI (coulomb)
//
// The others physical constants are defined in the header file :
// PhysicalConstants.h
//
// Authors: M.Maire, S.Giani
//
// History:
//
// 06.02.96 Created.
// 28.03.96 Added miscellaneous constants.
// 05.12.97 E.Tcherniaev: Redefined pascal (to avoid warnings on WinNT)
// 20.05.98 names: meter, second, gram, radian, degree. (from Blasiuk (STAR))
// Added luminous units.
// 05.08.98 angstrom,picobarn,microsecond,picosecond,petaelectronvolt
#ifndef HEP_SYSTEM_OF_UNITS_H
#define HEP_SYSTEM_OF_UNITS_H
#include "CLHEP/config/CLHEP.h"
//
// Length [L]
//
static const HepDouble millimeter = 1.;
static const HepDouble millimeter2 = millimeter*millimeter;
static const HepDouble millimeter3 = millimeter*millimeter*millimeter;
static const HepDouble centimeter = 10.*millimeter;
static const HepDouble centimeter2 = centimeter*centimeter;
static const HepDouble centimeter3 = centimeter*centimeter*centimeter;
static const HepDouble meter = 1000.*millimeter;
static const HepDouble meter2 = meter*meter;
static const HepDouble meter3 = meter*meter*meter;
static const HepDouble kilometer = 1000.*meter;
static const HepDouble kilometer2 = kilometer*kilometer;
static const HepDouble kilometer3 = kilometer*kilometer*kilometer;
static const HepDouble micrometer = 1.e-6 *meter;
static const HepDouble nanometer = 1.e-9 *meter;
static const HepDouble angstrom = 1.e-10*meter;
static const HepDouble fermi = 1.e-15*meter;
static const HepDouble barn = 1.e-28*meter2;
static const HepDouble millibarn = 1.e-3 *barn;
static const HepDouble microbarn = 1.e-6 *barn;
static const HepDouble nanobarn = 1.e-9 *barn;
static const HepDouble picobarn = 1.e-12*barn;
// symbols
static const HepDouble mm = millimeter;
static const HepDouble mm2 = millimeter2;
static const HepDouble mm3 = millimeter3;
static const HepDouble cm = centimeter;
static const HepDouble cm2 = centimeter2;
static const HepDouble cm3 = centimeter3;
static const HepDouble m = meter;
static const HepDouble m2 = meter2;
static const HepDouble m3 = meter3;
static const HepDouble km = kilometer;
static const HepDouble km2 = kilometer2;
static const HepDouble km3 = kilometer3;
//
// Angle
//
static const HepDouble radian = 1.;
static const HepDouble milliradian = 1.e-3*radian;
static const HepDouble degree = (3.14159265358979323846/180.0)*radian;
static const HepDouble steradian = 1.;
// symbols
static const HepDouble rad = radian;
static const HepDouble mrad = milliradian;
static const HepDouble sr = steradian;
static const HepDouble deg = degree;
//
// Time [T]
//
static const HepDouble nanosecond = 1.;
static const HepDouble second = 1.e+9 *nanosecond;
static const HepDouble millisecond = 1.e-3 *second;
static const HepDouble microsecond = 1.e-6 *second;
static const HepDouble picosecond = 1.e-12*second;
static const HepDouble hertz = 1./second;
static const HepDouble kilohertz = 1.e+3*hertz;
static const HepDouble megahertz = 1.e+6*hertz;
// symbols
static const HepDouble ns = nanosecond;
static const HepDouble s = second;
static const HepDouble ms = millisecond;
//
// Electric charge [Q]
//
static const HepDouble eplus = 1. ; // positron charge
static const HepDouble e_SI = 1.60217733e-19; // positron charge in coulomb
static const HepDouble coulomb = eplus/e_SI; // coulomb = 6.24150 e+18 * eplus
//
// Energy [E]
//
static const HepDouble megaelectronvolt = 1. ;
static const HepDouble electronvolt = 1.e-6*megaelectronvolt;
static const HepDouble kiloelectronvolt = 1.e-3*megaelectronvolt;
static const HepDouble gigaelectronvolt = 1.e+3*megaelectronvolt;
static const HepDouble teraelectronvolt = 1.e+6*megaelectronvolt;
static const HepDouble petaelectronvolt = 1.e+9*megaelectronvolt;
static const HepDouble joule = electronvolt/e_SI; // joule = 6.24150 e+12 * MeV
// symbols
static const HepDouble MeV = megaelectronvolt;
static const HepDouble eV = electronvolt;
static const HepDouble keV = kiloelectronvolt;
static const HepDouble GeV = gigaelectronvolt;
static const HepDouble TeV = teraelectronvolt;
static const HepDouble PeV = petaelectronvolt;
//
// Mass [E][T^2][L^-2]
//
static const HepDouble kilogram = joule*second*second/(meter*meter);
static const HepDouble gram = 1.e-3*kilogram;
static const HepDouble milligram = 1.e-3*gram;
// symbols
static const HepDouble kg = kilogram;
static const HepDouble g = gram;
static const HepDouble mg = milligram;
//
// Power [E][T^-1]
//
static const HepDouble watt = joule/second; // watt = 6.24150 e+3 * MeV/ns
//
// Force [E][L^-1]
//
static const HepDouble newton = joule/meter; // newton = 6.24150 e+9 * MeV/mm
//
// Pressure [E][L^-3]
//
#define pascal hep_pascal // a trick to avoid warnings
static const HepDouble hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
static const HepDouble bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
static const HepDouble atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
//
// Electric current [Q][T^-1]
//
static const HepDouble ampere = coulomb/second; // ampere = 6.24150 e+9 * eplus/ns
static const HepDouble milliampere = 1.e-3*ampere;
static const HepDouble microampere = 1.e-6*ampere;
static const HepDouble nanoampere = 1.e-9*ampere;
//
// Electric potential [E][Q^-1]
//
static const HepDouble megavolt = megaelectronvolt/eplus;
static const HepDouble kilovolt = 1.e-3*megavolt;
static const HepDouble volt = 1.e-6*megavolt;
//
// Electric resistance [E][T][Q^-2]
//
static const HepDouble ohm = volt/ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
//
// Electric capacitance [Q^2][E^-1]
//
static const HepDouble farad = coulomb/volt; // farad = 6.24150e+24 * eplus/Megavolt
static const HepDouble millifarad = 1.e-3*farad;
static const HepDouble microfarad = 1.e-6*farad;
static const HepDouble nanofarad = 1.e-9*farad;
static const HepDouble picofarad = 1.e-12*farad;
//
// Magnetic Flux [T][E][Q^-1]
//
static const HepDouble weber = volt*second; // weber = 1000*megavolt*ns
//
// Magnetic Field [T][E][Q^-1][L^-2]
//
static const HepDouble tesla = volt*second/meter2; // tesla =0.001*megavolt*ns/mm2
static const HepDouble gauss = 1.e-4*tesla;
static const HepDouble kilogauss = 1.e-1*tesla;
//
// Inductance [T^2][E][Q^-2]
//
static const HepDouble henry = weber/ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
//
// Temperature
//
static const HepDouble kelvin = 1.;
//
// Amount of substance
//
static const HepDouble mole = 1.;
//
// Activity [T^-1]
//
static const HepDouble becquerel = 1./second ;
static const HepDouble curie = 3.7e+10 * becquerel;
//
// Absorbed dose [L^2][T^-2]
//
static const HepDouble gray = joule/kilogram ;
//
// Luminous intensity [I]
//
static const HepDouble candela = 1.;
//
// Luminous flux [I]
//
static const HepDouble lumen = candela*steradian;
//
// Illuminance [I][L^-2]
//
static const HepDouble lux = lumen/meter2;
//
// Miscellaneous
//
static const HepDouble perCent = 0.01 ;
static const HepDouble perThousand = 0.001;
static const HepDouble perMillion = 0.000001;
#endif /* HEP_SYSTEM_OF_UNITS_H */
@@ -0,0 +1,87 @@
// 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: globals.hh,v 2.6 1998/09/24 01:06:22 gcosmo Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Global Constants and typedefs
//
// History:
// 30.06.95 P.Kent - Created
// 16.02.96 G.Cosmo - Added inclusion of "templates.hh"
// 03.03.96 M.Maire - Added inclusion of "G4PhysicalConstants.hh"
// 08.11.96 G.Cosmo - Added cbrt() definition and G4ApplicationState enum type
// 29.11.96 G.Cosmo - Added typedef of HepBoolean to G4bool
// 22.10.97 M.Maire - Moved PhysicalConstants at the end of the file
// 04.12.97 G.Cosmo,E.Tcherniaev - Migrated to CLHEP
// 05.06.98 M.Maire - temporary (for alpha07) restore G4 system of units
// 26.08.98 J.Allison,E.Tcherniaev - introduced min/max/sqr/abs functions
// 22.09.98 G.Cosmo - removed min/max/sqr/abs functions and replaced with
// inclusion of CLHEP/config/TemplateFunctions.h for CLHEP-1.3
#ifndef GLOBALS_HH
#define GLOBALS_HH
#include "G4ios.hh"
// Undefine possible existing min/max/sqr/abs macros first
// (temporary solution)
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#ifdef sqr
#undef sqr
#endif
#ifdef abs
#undef abs
#endif
// Includes also CLHEP.h with typedef for numeric types and
// implicit inclusions of <stdlib.h>, <limits.h>, <math.h>.
#include <CLHEP/config/TemplateFunctions.h>
// Typedefs to decouple from library classes
#include <rw/cstring.h>
typedef RWCString G4String;
// Typedefs for numeric types
// [NOTE: Will in future need to be made more sophisticated]
typedef HepDouble G4double;
typedef HepFloat G4float;
typedef HepInt G4int;
#ifdef G4_HAVE_BOOL
typedef bool G4bool;
#else
typedef HepBoolean G4bool;
#endif
typedef long G4long;
// Includes some additional definitions
#include "templates.hh"
// cbrt() function - define G4_NO_CBRT if the function is not available
#ifdef G4_NO_CBRT
static double cbrt(double x) { return pow(x,1./3.); }
#endif
// System of Units and Physical Constants
////#include <CLHEP/Units/PhysicalConstants.h>
#include "PhysicalConstants.h"
// Global error function
void G4Exception(const char* s=0);
#endif /* GLOBALS_HH */
@@ -0,0 +1,99 @@
// 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: templates.hh,v 2.0 1998/07/02 17:33:15 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// -*- C++ -*-
//
// -----------------------------------------------------------------------
// This file should define some platform dependent features and some
// useful utilities.
// -----------------------------------------------------------------------
// =======================================================================
// Gabriele Cosmo - Created: 5th September 1995
// Gabriele Cosmo - Minor change: 08/02/1996
// Gabriele Cosmo - Added DBL_MIN, FLT_MIN, DBL_DIG,
// DBL_MAX, FLT_DIG, FLT_MAX : 12/04/1996
// Gabriele Cosmo - Removed boolean enum definition : 29/11/1996
// Gunter Folger - Added G4SwapPtr() and G4SwapObj() : 31/07/1997
// Gabriele Cosmo - Adapted signatures of min(), max() to
// STL's ones, thanks to E.Tcherniaev : 31/07/1997
// Gabriele Cosmo,
// Evgueni Tcherniaev - Migrated to CLHEP: 04/12/1997
// =======================================================================
#ifndef templates_h
#define templates_h 1
//
// If HIGH_PRECISION is defined to TRUE (ie. != 0) then the type "Float"
// is typedefed to "double". If it is FALSE (ie. 0) it is typedefed
// to "float".
//
#ifndef HIGH_PRECISION
#define HIGH_PRECISION 1
#endif
#if HIGH_PRECISION
typedef double Float;
#else
typedef float Float;
#endif
// Following values have been taken from limits.h
// and temporarly defined for portability on HP-UX.
#ifndef DBL_MIN /* Min decimal value of a double */
#define DBL_MIN 2.2250738585072014e-308
#endif
#ifndef FLT_MIN /* Min decimal value of a float */
#define FLT_MIN 1.17549435e-38
#endif
#ifndef DBL_DIG /* Digits of precision of a double */
#define DBL_DIG 15
#endif
#ifndef DBL_MAX /* Max decimal value of a double */
#define DBL_MAX 1.7976931348623157e+308
#endif
#ifndef FLT_DIG /* Digits of precision of a float */
#define FLT_DIG 6
#endif
#ifndef FLT_MAX /* Max decimal value of a float */
#define FLT_MAX 3.40282347e+38
#endif
#ifndef MAXFLOAT /* Max decimal value of a float */
#define MAXFLOAT 3.40282347e+38
#endif
//---------------------------------
template <class T>
inline void G4SwapPtr(T* a, T* b) {
T* tmp=a;
a = b;
b = tmp;
}
template <class T>
inline void G4SwapObj(T* a, T* b) {
T tmp= *a;
*a = *b;
*b = tmp;
}
//-----------------------------
#endif // templates_h