Import Geant4 1.0.0 source tree
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4LorentzRotation.hh,v 1.1 1999/01/07 16:08:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4LorentzRotation.hh,v 1.2 1999/11/16 17:29:12 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4LorentzRotation_hh
|
||||
#define G4LorentzRotation_hh
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4LorentzVector.hh,v 1.1 1999/01/07 16:08:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4LorentzVector.hh,v 1.2 1999/11/16 17:29:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4LorentzVector_hh
|
||||
#define G4LorentzVector_hh
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Normal3D.hh,v 1.1 1999/01/07 16:08:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Normal3D.hh,v 1.2 1999/11/16 17:29:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4NORMAL3D_HH
|
||||
#define G4NORMAL3D_HH
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Plane3D.hh,v 1.1 1999/01/07 16:08:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Plane3D.hh,v 1.2 1999/11/16 17:29:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4PLANE3D_HH
|
||||
#define G4PLANE3D_HH
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Point3D.hh,v 1.1 1999/01/07 16:08:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Point3D.hh,v 1.2 1999/11/16 17:29:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4POINT3D_HH
|
||||
#define G4POINT3D_HH
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Transform3D.hh,v 1.1 1999/01/07 16:08:52 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Transform3D.hh,v 1.2 1999/11/16 17:29:14 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4TRANSFORM3D_HH
|
||||
#define G4TRANSFORM3D_HH
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Vector3D.hh,v 1.1 1999/01/07 16:08:52 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Vector3D.hh,v 1.2 1999/11/16 17:29:14 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef G4VECTOR3D_HH
|
||||
#define G4VECTOR3D_HH
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: geomdefs.hh,v 1.1 1999/01/07 16:08:52 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: geomdefs.hh,v 1.2 1999/11/16 17:29:14 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -60,8 +60,3 @@ enum EInside {kOutside,kSurface,kInside};
|
||||
enum EVolume {kNormal,kReplica,kParameterised};
|
||||
|
||||
#endif /* GeomDefs_hh */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4ChebyshevApproximation.hh,v 1.1 1999/01/07 16:08:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4ChebyshevApproximation.hh,v 1.2 1999/11/16 17:30:55 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class creating the Chebyshev approximation for a function pointed by fFunction
|
||||
// data member. The Chebyshev polinom approximation provides an efficient evaluation
|
||||
@@ -93,7 +95,7 @@
|
||||
// at the point (fMean - fDiff)
|
||||
//
|
||||
// void IntegralChebyshevCof(G4double integralCof[]) const
|
||||
//
|
||||
|
||||
// --------------------------- HISTORY --------------------------------------
|
||||
//
|
||||
// 24.04.97 V.Grichine ( Vladimir.Grichine@cern.ch )
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4DataInterpolation.hh,v 1.1 1999/01/07 16:08:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4DataInterpolation.hh,v 1.2 1999/11/16 17:30:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// The class consists of some methods for data interpolations and extrapolations.
|
||||
// The methods based mainly on recommendations given in the book : An introduction to
|
||||
@@ -81,14 +83,14 @@
|
||||
// decreasing. If index = -1 or fNumber, this indicates that pX is out of range.
|
||||
// The value index on input is taken as the initial approximation for index on
|
||||
// output.
|
||||
//
|
||||
|
||||
// --------------------------------- History: --------------------------------------
|
||||
//
|
||||
// 3.4.97 V.Grichine (Vladimir.Grichine@cern.ch)
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4DATAINTERPOLATION_HH
|
||||
#ifndef G4DATAINTERPOLATION_HH
|
||||
#define G4DATAINTERPOLATION_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussChebyshevQ.hh,v 1.1 1999/01/07 16:08:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussChebyshevQ.hh,v 1.2 1999/11/16 17:30:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for Gauss-Chebyshev quadrature method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
@@ -30,7 +32,7 @@
|
||||
// method
|
||||
//
|
||||
// G4double Integral(G4double a, G4double b) const
|
||||
//
|
||||
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussHermiteQ.hh,v 1.1 1999/01/07 16:08:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussHermiteQ.hh,v 1.2 1999/11/16 17:30:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
@@ -27,8 +29,7 @@
|
||||
// to plus infinity .
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
//
|
||||
|
||||
// ------------------------------- HISTORY -------------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussJacobiQ.hh,v 1.1 1999/01/07 16:08:54 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussJacobiQ.hh,v 1.2 1999/11/16 17:30:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
@@ -29,7 +31,7 @@
|
||||
// from minus unit to plus unit .
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
|
||||
// ------------------------------- HISTORY -------------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussLaguerreQ.hh,v 1.1 1999/01/07 16:08:54 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussLaguerreQ.hh,v 1.2 1999/11/16 17:30:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for realization of Gauss-Laguerre quadrature method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
@@ -35,7 +37,7 @@
|
||||
// fAbscissa[i] and fWeight[i] arrays were created in constructor
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussLegendreQ.hh,v 1.1 1999/01/07 16:08:54 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussLegendreQ.hh,v 1.2 1999/11/16 17:30:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for Gauss-Legendre integration method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
@@ -57,7 +59,7 @@
|
||||
//
|
||||
// G4double
|
||||
// AccurateIntegral(G4double a, G4double b) const
|
||||
//
|
||||
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
// 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: G4Integrator.hh,v 1.3 1999/11/16 17:30:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class collecting template integrator methods for generic funtions.
|
||||
|
||||
// History:
|
||||
//
|
||||
// 04.09.99 V.Grichine, first implementation based on G4SimpleIntegration class
|
||||
// and H.-P. Wellisch, G.Cosmo, and E.Cherniaev advises
|
||||
// 08.09.99 V.Grichine, methods involving orthogonal polynomials
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4INTEGRATOR_HH
|
||||
#define G4INTEGRATOR_HH 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include <math.h>
|
||||
|
||||
class G4Integrator
|
||||
{
|
||||
public:
|
||||
|
||||
G4Integrator(){;}
|
||||
|
||||
~G4Integrator(){;}
|
||||
|
||||
// Simpson integration method
|
||||
|
||||
template <class T, class F> G4double
|
||||
Simpson( T& typeT, F f, G4double a, G4double b, G4int n ) ;
|
||||
|
||||
template <class T, class F> G4double
|
||||
Simpson( T* ptrT, F f, G4double a, G4double b, G4int n ) ;
|
||||
|
||||
G4double Simpson( G4double (*f)(G4double),
|
||||
G4double a, G4double b, G4int n ) ;
|
||||
|
||||
// Adaptive Gauss method
|
||||
|
||||
template <class T, class F> G4double
|
||||
AdaptiveGauss( T& typeT, F f, G4double a, G4double b, G4double e ) ;
|
||||
|
||||
template <class T, class F> G4double
|
||||
AdaptiveGauss( T* ptrT, F f, G4double a, G4double b, G4double e ) ;
|
||||
|
||||
G4double AdaptiveGauss( G4double (*f)(G4double),
|
||||
G4double a, G4double b, G4double e ) ;
|
||||
|
||||
// Integration methods involving orthogohol polynomials
|
||||
|
||||
// Methods involving Legendre polynomials
|
||||
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre( T& typeT, F f, G4double a, G4double b, G4int n) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre( T* ptrT, F f, G4double a, G4double b, G4int n) ;
|
||||
|
||||
G4double Legendre( G4double (*f)(G4double), G4double a, G4double b, G4int n) ;
|
||||
|
||||
// Legendre10 is very fast and accurate anough
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre10( T& typeT, F f,G4double a, G4double b) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre10( T* ptrT, F f,G4double a, G4double b) ;
|
||||
|
||||
G4double Legendre10( G4double (*f)(G4double), G4double a, G4double b) ;
|
||||
|
||||
// Legendre96 is very accurate and fast enough
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre96( T& typeT, F f,G4double a, G4double b) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Legendre96( T* ptrT, F f,G4double a, G4double b) ;
|
||||
|
||||
G4double Legendre96( G4double (*f)(G4double), G4double a, G4double b) ;
|
||||
|
||||
// Methods involving Chebyshev polynomials
|
||||
|
||||
template <class T, class F>
|
||||
G4double Chebyshev( T& typeT, F f, G4double a, G4double b, G4int n) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Chebyshev( T* ptrT, F f, G4double a, G4double b, G4int n) ;
|
||||
|
||||
G4double Chebyshev( G4double (*f)(G4double), G4double a, G4double b, G4int n) ;
|
||||
|
||||
// Method involving Laguerre polynomials
|
||||
|
||||
template <class T, class F>
|
||||
G4double Laguerre( T& typeT, F f, G4double alpha, G4int n) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Laguerre( T* ptrT, F f, G4double alpha, G4int n) ;
|
||||
|
||||
G4double Laguerre( G4double (*f)(G4double), G4double alpha, G4int n) ;
|
||||
|
||||
// Method involving Hermite polynomials
|
||||
|
||||
template <class T, class F>
|
||||
G4double Hermite( T& typeT, F f, G4int n) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Hermite( T* ptrT, F f, G4int n) ;
|
||||
|
||||
G4double Hermite( G4double (*f)(G4double), G4int n) ;
|
||||
|
||||
// Method involving Jacobi polynomials
|
||||
|
||||
template <class T, class F>
|
||||
G4double Jacobi( T& typeT, F f, G4double alpha, G4double beta, G4int n) ;
|
||||
|
||||
template <class T, class F>
|
||||
G4double Jacobi( T* ptrT, F f, G4double alpha, G4double beta, G4int n) ;
|
||||
|
||||
G4double Jacobi( G4double (*f)(G4double), G4double alpha,
|
||||
G4double beta, G4int n) ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Auxiliary function for adaptive Gauss method
|
||||
|
||||
template <class T, class F> G4double
|
||||
Gauss( T& typeT, F f, G4double a, G4double b ) ;
|
||||
|
||||
template <class T, class F> G4double
|
||||
Gauss( T* ptrT, F f, G4double a, G4double b ) ;
|
||||
|
||||
G4double Gauss( G4double (*f)(G4double), G4double a, G4double b) ;
|
||||
|
||||
//
|
||||
|
||||
template <class T, class F> void
|
||||
AdaptGauss( T& typeT, F f, G4double a, G4double b,
|
||||
G4double e, G4double& sum, G4int& n) ;
|
||||
|
||||
template <class T, class F> void
|
||||
AdaptGauss( T* typeT, F f, G4double a, G4double b,
|
||||
G4double e, G4double& sum, G4int& n ) ;
|
||||
|
||||
void AdaptGauss( G4double (*f)(G4double), G4double a, G4double b,
|
||||
G4double e, G4double& sum, G4int& n ) ;
|
||||
|
||||
G4double GammaLogarithm(G4double xx) ;
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
#include "G4Integrator.icc"
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4SimpleIntegration.hh,v 1.1 1999/01/07 16:08:54 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4SimpleIntegration.hh,v 1.2 1999/11/16 17:30:59 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for realisation of simple numerical methodes for integration of functions
|
||||
// with signature: double f(double). The methods based mainly on algorithms given in
|
||||
@@ -29,7 +31,7 @@
|
||||
//
|
||||
// AdaptGausIntegration(double a, double b) - integrate function from a to be with
|
||||
// accuracy <= fTolerance
|
||||
//
|
||||
|
||||
// ----------------------------- History: ----------------------------------------
|
||||
//
|
||||
// 26.03.97 V.Grichine ( Vladimir.Grichine@cern.ch )
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4VGaussianQuadrature.hh,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4VGaussianQuadrature.hh,v 1.2 1999/11/16 17:30:59 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Base Class for realisation of numerical methodes for integration of functions
|
||||
// with signature double f(double) by Gaussian quadrature methods
|
||||
@@ -30,7 +32,7 @@
|
||||
//
|
||||
// G4double
|
||||
// GammaLogarithm(G4double xx)
|
||||
//
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// History:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4ChebyshevApproximation.cc,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4ChebyshevApproximation.cc,v 1.2 1999/11/16 17:31:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
|
||||
#include "G4ChebyshevApproximation.hh"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4DataInterpolation.cc,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4DataInterpolation.cc,v 1.3 1999/11/16 17:31:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4DataInterpolation.hh"
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
G4DataInterpolation::G4DataInterpolation( G4double pX[],
|
||||
G4double pY[],
|
||||
G4int number )
|
||||
G4int number ):
|
||||
fSecondDerivative (0)
|
||||
{
|
||||
G4int i ;
|
||||
fNumber = number ;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussChebyshevQ.cc,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussChebyshevQ.cc,v 1.2 1999/11/16 17:31:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4GaussChebyshevQ.hh"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussHermiteQ.cc,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussHermiteQ.cc,v 1.2 1999/11/16 17:31:10 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4GaussHermiteQ.hh"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussJacobiQ.cc,v 1.1 1999/01/07 16:08:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussJacobiQ.cc,v 1.2 1999/11/16 17:31:10 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4GaussJacobiQ.hh"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussLaguerreQ.cc,v 1.1 1999/01/07 16:08:56 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussLaguerreQ.cc,v 1.2 1999/11/16 17:31:10 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4GaussLaguerreQ.hh"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4GaussLegendreQ.cc,v 1.1 1999/01/07 16:08:56 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4GaussLegendreQ.cc,v 1.2 1999/11/16 17:31:10 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#include "G4GaussLegendreQ.hh"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4SimpleIntegration.cc,v 1.1 1999/01/07 16:08:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4SimpleIntegration.cc,v 1.2 1999/11/16 17:31:11 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Implementation file for simple integration methods
|
||||
//
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4VGaussianQuadrature.cc,v 1.1 1999/01/07 16:08:57 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4VGaussianQuadrature.cc,v 1.2 1999/11/16 17:31:11 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// Implementation file for G4VGaussianQuadrature virtual base class
|
||||
//
|
||||
|
||||
@@ -5,24 +5,21 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Poisson.hh,v 1.2 1999/05/11 19:43:11 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Poisson.hh,v 1.4 1999/11/16 17:31:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// For information related to this code contact:
|
||||
// CERN, IT Division, ASD group
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// Description:
|
||||
// -----------
|
||||
// Class description:
|
||||
//
|
||||
// G4Poisson is the C++ implementation of the CERNLIB GPOISS algorithm
|
||||
// for the generation of Gaussian distributed random numbers. It has been
|
||||
// for the generation of Poisson distributed random numbers. It has been
|
||||
// adapted to invoke HepRandom from CLHEP for the primary engine generators.
|
||||
// GPOISS is recognized to be a faster algorithm, providing however a less
|
||||
// accurate output, than the algorithm adopted in CLHEP.
|
||||
|
||||
// ------------------------------------------------------------
|
||||
#ifndef G4POISSON_HH
|
||||
#define G4POISSON_HH
|
||||
@@ -30,7 +27,7 @@
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
G4long G4Poisson(G4double mean)
|
||||
inline G4long G4Poisson(G4double mean)
|
||||
{
|
||||
G4long number = 0;
|
||||
const G4int border = 16;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: Randomize.hh,v 1.1 1999/01/07 16:08:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: Randomize.hh,v 1.2 1999/11/16 17:31:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
#ifndef randomize_h
|
||||
#define randomize_h 1
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
// 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: G4RandDistributionTest.cc,v 1.3 1999/11/23 15:00:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
#include "Randomize.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
HepJamesRandom theJamesEngine;
|
||||
RandEngine theRandEngine;
|
||||
DRand48Engine theDRand48Engine;
|
||||
RanluxEngine theRanluxEngine(19780503,4);
|
||||
RanecuEngine theRanecuEngine;
|
||||
|
||||
void init()
|
||||
{
|
||||
char Pause;
|
||||
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "---------------------------- Random shooting test -----------------------------" << G4endl;
|
||||
G4cout << " -------------------- " << G4endl;
|
||||
G4cout << " >>> Random Engines available <<<" << G4endl << G4endl;
|
||||
G4cout << " > HepJamesRandom (default)" << G4endl;
|
||||
G4cout << " > Rand" << G4endl;
|
||||
G4cout << " > DRand48" << G4endl;
|
||||
G4cout << " > Ranlux" << G4endl;
|
||||
G4cout << " > Ranecu" << G4endl << G4endl;
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
|
||||
} // end init()
|
||||
|
||||
|
||||
void layout()
|
||||
{
|
||||
HepFloat m=3.0;
|
||||
const HepInt size=5;
|
||||
HepDouble vect[size];
|
||||
|
||||
G4cout << " Flat ]0,1[ : " << RandFlat::shoot() << G4endl;
|
||||
G4cout << " Flat ]0,5[ : " << RandFlat::shoot(5) << G4endl;
|
||||
G4cout << " Flat ]-5,3[ : " << RandFlat::shoot(-5,3) << G4endl;
|
||||
G4cout << " Exp (m=1) : " << RandExponential::shoot() << G4endl;
|
||||
G4cout << " Exp (m=3) : " << RandExponential::shoot(3) << G4endl;
|
||||
G4cout << " Gauss (m=1) : " << RandGauss::shoot() << G4endl;
|
||||
G4cout << " Gauss (m=3,v=1) : " << RandGauss::shoot(3,1) << G4endl;
|
||||
G4cout << " Wigner(1,0.2) : " << RandBreitWigner::shoot(1,0.2) << G4endl;
|
||||
G4cout << " Wigner(1,0.2,1) : " << RandBreitWigner::shoot(1,0.2,1) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2) : " << RandBreitWigner::shootM2(1,0.2) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2,1) : " << RandBreitWigner::shootM2(1,0.2,1) << G4endl;
|
||||
G4cout << " IntFlat [0,99[ : " << RandFlat::shootInt(99) << G4endl;
|
||||
G4cout << " IntFlat [-99,37[ : " << RandFlat::shootInt(-99,37) << G4endl;
|
||||
G4cout << " Poisson (m=3.0) : " << RandPoisson::shoot(m) << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " Shooting an array of 5 flat numbers ..." << G4endl << G4endl;
|
||||
RandFlat::shootArray(size,vect);
|
||||
for ( HepInt i=0; i<size; ++i )
|
||||
G4cout << " " << vect[i];
|
||||
G4cout << G4endl << G4endl;
|
||||
} // end layout()
|
||||
|
||||
void dist_layout()
|
||||
{
|
||||
HepFloat m=3.0;
|
||||
const HepInt size=5;
|
||||
HepDouble vect[size];
|
||||
char Pause;
|
||||
|
||||
HepJamesRandom aJamesEngine;
|
||||
RandEngine aRandEngine;
|
||||
DRand48Engine aDRand48Engine;
|
||||
RanluxEngine aRanluxEngine(19780503,4);
|
||||
RanecuEngine aRanecuEngine;
|
||||
|
||||
RandFlat aFlatObj(aJamesEngine);
|
||||
RandExponential anExponentialObj(aRandEngine);
|
||||
RandGauss aGaussObj(aDRand48Engine);
|
||||
RandBreitWigner aBreitObj(aRanluxEngine);
|
||||
RandPoisson aPoissonObj(aRanecuEngine);
|
||||
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << "-------------------- Shooting test on distribution objects --------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " Flat ]0,1[ : " << aFlatObj.fire() << G4endl;
|
||||
G4cout << " Flat ]0,5[ : " << aFlatObj.fire(5) << G4endl;
|
||||
G4cout << " Flat ]-5,3[ : " << aFlatObj.fire(-5,3) << G4endl;
|
||||
G4cout << " Exp (m=1) : " << anExponentialObj.fire() << G4endl;
|
||||
G4cout << " Exp (m=3) : " << anExponentialObj.fire(3) << G4endl;
|
||||
G4cout << " Gauss (m=1) : " << aGaussObj.fire() << G4endl;
|
||||
G4cout << " Gauss (m=3,v=1) : " << aGaussObj.fire(3,1) << G4endl;
|
||||
G4cout << " Wigner(1,0.2) : " << aBreitObj.fire(1,0.2) << G4endl;
|
||||
G4cout << " Wigner(1,0.2,1) : " << aBreitObj.fire(1,0.2,1) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2) : " << aBreitObj.fireM2(1,0.2) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2,1) : " << aBreitObj.fireM2(1,0.2,1) << G4endl;
|
||||
G4cout << " IntFlat [0,99[ : " << aFlatObj.fireInt(99) << G4endl;
|
||||
G4cout << " IntFlat [-99,37[ : " << aFlatObj.fireInt(-99,37) << G4endl;
|
||||
G4cout << " Poisson (m=3.0) : " << aPoissonObj.fire(m) << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " Shooting an array of 5 flat numbers ..." << G4endl << G4endl;
|
||||
aFlatObj.fireArray(size,vect);
|
||||
for ( HepInt i=0; i<size; ++i )
|
||||
G4cout << " " << vect[i];
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
} // end dist_layout()
|
||||
|
||||
void user_layout()
|
||||
{
|
||||
HepFloat m=3.0;
|
||||
const HepInt size=5;
|
||||
HepDouble vect[size];
|
||||
char sel;
|
||||
HepRandomEngine* anEngine;
|
||||
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "-------------------- Shooting test skeeping the generator ---------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " >>> Select a Random Engine <<<" << G4endl << G4endl;
|
||||
G4cout << " 1. HepJamesRandom (default)" << G4endl;
|
||||
G4cout << " 2. Rand" << G4endl;
|
||||
G4cout << " 3. DRand48" << G4endl;
|
||||
G4cout << " 4. Ranlux" << G4endl;
|
||||
G4cout << " 5. Ranecu" << G4endl << G4endl;
|
||||
G4cout << " > ";
|
||||
G4cin >> sel;
|
||||
while ((sel!='1')&&(sel!='2')&&(sel!='3')&&(sel!='4')&&(sel!='5')) {
|
||||
G4cout << G4endl << " >>> Choice not legal !! [1..5]<<<" << G4endl;
|
||||
G4cin >> sel;
|
||||
}
|
||||
|
||||
switch (sel) {
|
||||
case '1':
|
||||
anEngine = &theJamesEngine;
|
||||
break;
|
||||
case '2':
|
||||
anEngine = &theRandEngine;
|
||||
break;
|
||||
case '3':
|
||||
anEngine = &theDRand48Engine;
|
||||
break;
|
||||
case '4':
|
||||
anEngine = &theRanluxEngine;
|
||||
break;
|
||||
case '5':
|
||||
anEngine = &theRanecuEngine;
|
||||
break;
|
||||
|
||||
default:
|
||||
anEngine = &theJamesEngine;
|
||||
break;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
|
||||
G4cout << " Flat ]0,1[ : " << RandFlat::shoot(anEngine) << G4endl;
|
||||
G4cout << " Flat ]0,5[ : " << RandFlat::shoot(anEngine,5) << G4endl;
|
||||
G4cout << " Flat ]-5,3[ : " << RandFlat::shoot(anEngine,-5,3) << G4endl;
|
||||
G4cout << " Exp (m=1) : " << RandExponential::shoot(anEngine) << G4endl;
|
||||
G4cout << " Exp (m=3) : " << RandExponential::shoot(anEngine,3) << G4endl;
|
||||
G4cout << " Gauss (m=1) : " << RandGauss::shoot(anEngine) << G4endl;
|
||||
G4cout << " Gauss (m=3,v=1) : " << RandGauss::shoot(anEngine,3,1) << G4endl;
|
||||
G4cout << " Wigner(1,0.2) : " << RandBreitWigner::shoot(anEngine,1,0.2) << G4endl;
|
||||
G4cout << " Wigner(1,0.2,1) : " << RandBreitWigner::shoot(anEngine,1,0.2,1) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2) : " << RandBreitWigner::shootM2(anEngine,1,0.2) << G4endl;
|
||||
G4cout << " Wigner2(1,0.2,1) : " << RandBreitWigner::shootM2(anEngine,1,0.2,1) << G4endl;
|
||||
G4cout << " IntFlat [0,99[ : " << RandFlat::shootInt(anEngine,99) << G4endl;
|
||||
G4cout << " IntFlat [-99,37[ : " << RandFlat::shootInt(anEngine,-99,37) << G4endl;
|
||||
G4cout << " Poisson (m=3.0) : " << RandPoisson::shoot(anEngine,m) << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " Shooting an array of 5 flat numbers ..." << G4endl << G4endl;
|
||||
RandFlat::shootArray(anEngine,size,vect);
|
||||
for ( HepInt i=0; i<size; ++i )
|
||||
G4cout << " " << vect[i];
|
||||
G4cout << G4endl << G4endl;
|
||||
} // end layout()
|
||||
|
||||
void start_test()
|
||||
{
|
||||
char Pause;
|
||||
|
||||
G4cout << "------------------------- Test on HepJamesRandom ----------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
layout();
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
G4cout << "--------------------------- Test on RandEngine ------------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRandEngine);
|
||||
layout();
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
G4cout << "------------------------- Test on DRand48Engine -----------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theDRand48Engine);
|
||||
layout();
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
G4cout << "--------------------- Test on RanluxEngine (luxury 4) ------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRanluxEngine);
|
||||
layout();
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
G4cout << "-------------------------- Test on RanecuEngine ------------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRanecuEngine);
|
||||
layout();
|
||||
dist_layout();
|
||||
user_layout();
|
||||
} // end start_test()
|
||||
|
||||
|
||||
HepInt main() {
|
||||
|
||||
init();
|
||||
start_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
// 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: G4RandGlobalTest.cc,v 1.3 1999/11/23 15:00:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
#include "Randomize.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
RandEngine theRandEngine;
|
||||
DRand48Engine theDRand48Engine;
|
||||
RanluxEngine theRanluxEngine(19780503,4);
|
||||
RanecuEngine theRanecuEngine;
|
||||
|
||||
//======================== CHI-SQUARED TEST ============================
|
||||
|
||||
HepInt box[10], chi[8], more=1;
|
||||
HepInt prob[8] = { 1, 5, 25, 50, 75, 95, 99, 100 };
|
||||
HepFloat perc[8] = { 2.09, 3.33, 5.90, 8.34, 11.39, 16.92, 21.67, 100.0 };
|
||||
|
||||
void even_test(HepInt seq)
|
||||
{
|
||||
HepInt i,j;
|
||||
char Pause;
|
||||
|
||||
for (i=0; i<8; ++i)
|
||||
chi[i]=0;
|
||||
|
||||
G4cout << "\t\t\t --- CHI-SQUARED TEST ---" << G4endl;
|
||||
HepInt fac = HepInt(seq/100);
|
||||
|
||||
G4cout << G4endl;
|
||||
|
||||
for (HepInt k=0; k<seq; ++k) {
|
||||
for (i=0; i<10; ++i)
|
||||
box[i]=0;
|
||||
for (i=0; i<1000; ++i) {
|
||||
HepInt h = HepInt(100*G4UniformRand());
|
||||
for (j=0; j<10; ++j)
|
||||
if ((10*j <= h) && (h < 10*(j+1))) ++box[j];
|
||||
}
|
||||
HepFloat X=0;
|
||||
for (i=0; i<10; ++i) {
|
||||
HepFloat t=HepFloat(box[i]-100);
|
||||
X += t*t;
|
||||
}
|
||||
X /= 100;
|
||||
if (k == (seq%100)) {
|
||||
G4cout << "\tDistribution of a single run (rand_valuex100) ..."
|
||||
<< G4endl << G4endl;
|
||||
G4cout << "\t\t 1 10 20 30 40 50 60 70 80 90 100" << G4endl;
|
||||
G4cout << "\t\t";
|
||||
for (j=0; j<10; ++j)
|
||||
G4cout << box[j] << " ";
|
||||
G4cout << G4endl;
|
||||
G4cout << "\t\t\t Chi-squared = " << X << G4endl << G4endl;
|
||||
}
|
||||
for (i=0; i<8; ++i)
|
||||
if (X <= perc[i]) ++chi[i];
|
||||
}
|
||||
G4cout << "\tDistribution of Chi-squared for " << seq << " sequences ..."
|
||||
<< G4endl << G4endl;
|
||||
G4cout << "\t\t\t %" << "\tChi-sq " << "\tExpected" << G4endl;
|
||||
for (j=0; j<8; ++j)
|
||||
G4cout << "\t\t\tX <= " << perc[j] << ":\t" << chi[j]/fac
|
||||
<< "\t" << prob[j] << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
if (more == 1)
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
} // end even_test()
|
||||
|
||||
//====================== SERIAL CORRELATION TEST =======================
|
||||
|
||||
void corr_test(HepInt seq)
|
||||
{
|
||||
HepInt i,j;
|
||||
char Pause;
|
||||
HepDouble U;
|
||||
HepDouble UU;
|
||||
HepDouble UV;
|
||||
HepDouble corr = 0.;
|
||||
HepDouble stde = 0.;
|
||||
HepDouble mv = -1./999;
|
||||
HepDouble std = (-mv)*sqrt(HepDouble(1000*(997)/(1001)));
|
||||
HepDouble next, uni, w, mve, temp[10000];
|
||||
|
||||
G4cout << "\t\t\t--- SERIAL CORRELATION TEST ---" << G4endl << G4endl;
|
||||
|
||||
for (j=0; j<seq; ++j) {
|
||||
U = 0.; UU = 0.; UV = 0.;
|
||||
uni = G4UniformRand();
|
||||
w = uni;
|
||||
for (i=1; i<1000; ++i) {
|
||||
next = G4UniformRand();
|
||||
U += next;
|
||||
UU += next*next;
|
||||
UV += uni*next;
|
||||
uni = next;
|
||||
}
|
||||
U += w;
|
||||
UU += w*w;
|
||||
UV += uni*w;
|
||||
temp[j] = (1000*UV-U*U)/(1000*UU-U*U);
|
||||
corr += temp[j];
|
||||
}
|
||||
|
||||
mve = corr/seq;
|
||||
for (j=0; j<seq; ++j) {
|
||||
temp[j] -= mve;
|
||||
stde += temp[j]*temp[j];
|
||||
}
|
||||
stde = sqrt((1./(seq-1))*stde);
|
||||
|
||||
G4cout << "Mean value predicted : " << mv << "\t"
|
||||
<< "Standard deviation predicted: " << std << G4endl
|
||||
<< "Mean value effective : " << mve << "\t"
|
||||
<< "Standard deviation effective: " << stde << G4endl << G4endl;
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
|
||||
} // end corr_test
|
||||
|
||||
//=========================== SPATIAL TEST =============================
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
static unsigned long twotoj[16] = { 0x1L,0x2L,0x4L,0x8L,0x10L,0x20L,0x40L,
|
||||
0x80L,0x100L,0x200L,0x400L,0x800L,
|
||||
0x1000L,0x2000L,0x4000L,0x8000L };
|
||||
|
||||
HepFloat fnc(HepFloat x1, HepFloat x2, HepFloat x3, HepFloat x4)
|
||||
{
|
||||
return (HepFloat) sqrt(x1*x1+x2*x2+x3*x3+x4*x4);
|
||||
}
|
||||
|
||||
void spat_test ()
|
||||
{
|
||||
char Pause;
|
||||
long iy[4],jpower,k;
|
||||
HepInt i,j;
|
||||
HepFloat x1,x2,x3,x4,yprob[4];
|
||||
|
||||
G4cout << "\t\t\t --- SPATIAL TEST ---" << G4endl
|
||||
<< "\tCalculates PI statistically using volume of unit n-sphere "
|
||||
<< "n = 2,3,4"
|
||||
<< G4endl << G4endl;
|
||||
for (i=1; i<=3; i++) iy[i]=0;
|
||||
G4cout << "\t\t\t# pts\tPI\t(4/3)PI\t(1/2)PI^2" << G4endl << G4endl;
|
||||
for (j=1; j<=15; j++) {
|
||||
for (k=twotoj[j-1]; k>=0; k--) {
|
||||
x1 = (HepFloat) G4UniformRand();
|
||||
x2 = (HepFloat) G4UniformRand();
|
||||
x3 = (HepFloat) G4UniformRand();
|
||||
x4 = (HepFloat) G4UniformRand();
|
||||
if (fnc(x1,x2,0.,0.) < 1.) ++iy[1];
|
||||
if (fnc(x1,x2,x3,0.) < 1.) ++iy[2];
|
||||
if (fnc(x1,x2,x3,x4) < 1.) ++iy[3];
|
||||
}
|
||||
jpower = twotoj[j];
|
||||
for (i=1; i<=3; i++)
|
||||
yprob[i] = (HepFloat) twotoj[i+1]*iy[i]/jpower;
|
||||
if ((jpower <= 32768) && (jpower != 0))
|
||||
G4cout << "\t\t\t" << jpower << "\t" << yprob[1] << "\t"
|
||||
<< yprob[2] << "\t" << yprob[3] << G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
G4cout << "\t\t\tactual" << "\t" << PI << "\t"
|
||||
<< 4.*PI/3. << "\t" << .5*PI*PI << G4endl << G4endl;
|
||||
|
||||
if (more != 99) {
|
||||
G4cout << " ----- Press <ENTER> to continue -----";
|
||||
if ( (Pause = G4cin.get()) != '\n') exit(0);
|
||||
G4cout << G4endl;
|
||||
}
|
||||
} // end spat_test()
|
||||
|
||||
//============================= GLOBAL =================================
|
||||
|
||||
void init()
|
||||
{
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "-------------------------- Random distribution test ---------------------------" << G4endl;
|
||||
G4cout << " ------------------------ " << G4endl;
|
||||
G4cout << " >>> Random Engines available <<< " << G4endl << G4endl;
|
||||
G4cout << " > HepJamesRandom (default)" << G4endl;
|
||||
G4cout << " > Rand" << G4endl;
|
||||
G4cout << " > DRand48" << G4endl;
|
||||
G4cout << " > Ranlux" << G4endl;
|
||||
G4cout << " > Ranecu" << G4endl << G4endl;
|
||||
G4cout << " >>> Tests performed <<< " << G4endl << G4endl;
|
||||
G4cout << " > Even distribution test" << G4endl;
|
||||
G4cout << " > Serial correlation test" << G4endl;
|
||||
G4cout << " > Spatial test" << G4endl;
|
||||
G4cout << G4endl << G4endl;
|
||||
|
||||
} // end init()
|
||||
|
||||
|
||||
void layout(HepInt seq)
|
||||
{
|
||||
even_test(seq);
|
||||
corr_test(seq);
|
||||
spat_test();
|
||||
} // end layout()
|
||||
|
||||
|
||||
void start_test()
|
||||
{
|
||||
char sel;
|
||||
HepInt seq;
|
||||
|
||||
G4cout << " Select the number of random values sequences:" << G4endl;
|
||||
G4cout << "\t a - 100 sequences of 1000 random values" << G4endl;
|
||||
G4cout << "\t b - 1000 sequences of 1000 random values" << G4endl;
|
||||
G4cout << "\t c - 10000 sequences of 1000 random values" << G4endl;
|
||||
G4cout << " > ";
|
||||
G4cin >> sel;
|
||||
if ((sel!='a')&&(sel!='b')&&(sel!='c'))
|
||||
exit(0);
|
||||
switch (sel) {
|
||||
case 'a':
|
||||
seq = 100;
|
||||
break;
|
||||
case 'b':
|
||||
seq = 1000;
|
||||
break;
|
||||
case 'c':
|
||||
seq = 10000;
|
||||
break;
|
||||
default:
|
||||
seq = 100;
|
||||
break;
|
||||
}
|
||||
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "------------------------- Test on HepJamesRandom ----------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
layout(seq);
|
||||
G4cout << G4endl << G4endl;
|
||||
more = 0;
|
||||
G4cout << "--------------------------- Test on RandEngine ------------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRandEngine);
|
||||
layout(seq);
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "------------------------- Test on DRand48Engine -----------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theDRand48Engine);
|
||||
layout(seq);
|
||||
G4cout << G4endl << G4endl;
|
||||
G4cout << "--------------------- Test on RanluxEngine (luxury 4) ------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRanluxEngine);
|
||||
layout(seq);
|
||||
G4cout << G4endl << G4endl;
|
||||
more = 99;
|
||||
G4cout << "-------------------------- Test on RanecuEngine ------------------------------" << G4endl;
|
||||
G4cout << G4endl;
|
||||
HepRandom::setTheEngine(&theRanecuEngine);
|
||||
layout(seq);
|
||||
} // end start_test()
|
||||
|
||||
|
||||
HepInt main() {
|
||||
|
||||
init();
|
||||
start_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// 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: G4ShootBitTest.cc,v 1.3 1999/11/23 15:00:01 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
|
||||
// Tests RandFlat::fireBit() member function
|
||||
// Peter Urban, 5th Sep 1996
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "g4std/iomanip.h"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Timer.hh"
|
||||
|
||||
int main()
|
||||
{
|
||||
HepRandomEngine* e= HepRandom::getTheEngine();
|
||||
RandFlat r(*e);
|
||||
|
||||
const long NumTest= 10000;
|
||||
|
||||
G4cout << "Printed value: (relative frequency - probability)" << G4endl;
|
||||
G4cout << NumTest << " random numbers" << G4endl << G4endl;
|
||||
|
||||
long sum= 0;
|
||||
long i, j;
|
||||
|
||||
for (i=0; i<NumTest; i++) {
|
||||
sum+= r.fireBit();
|
||||
}
|
||||
G4cout << "fireBit " << double(sum)/NumTest-0.5 << G4endl;
|
||||
sum= 0;
|
||||
for (i=0; i<NumTest; i++) {
|
||||
sum+= r.shootBit();
|
||||
}
|
||||
G4cout << "shootBit " << double(sum)/NumTest-0.5 << G4endl;
|
||||
sum= 0;
|
||||
for (i=0; i<NumTest; i++) {
|
||||
sum+= r.shootBit(e);
|
||||
}
|
||||
G4cout << "shootBit(engine) " << double(sum)/NumTest-0.5 << G4endl;
|
||||
|
||||
|
||||
const long Num= 1000000;
|
||||
int iii; long lll;
|
||||
|
||||
G4Timer theTimer;
|
||||
G4cout << G4endl << "Performance test: " << G4endl;
|
||||
|
||||
G4cout << "shootBit() vs G4UniformRand()<0.5: ";
|
||||
theTimer.Start();
|
||||
for (i=0; i<Num; i++)
|
||||
iii = RandFlat::shootBit();
|
||||
theTimer.Stop();
|
||||
G4cout << theTimer.GetUserElapsed() << " vs ";
|
||||
theTimer.Start();
|
||||
for (i=0; i<Num; i++)
|
||||
G4UniformRand()<0.5;
|
||||
theTimer.Stop();
|
||||
G4cout << theTimer.GetUserElapsed() << G4endl << G4endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# $Id: GNUmakefile,v 1.1 1999/01/07 16:08:59 gunter Exp $
|
||||
# ----------------------------------------------------------------
|
||||
# Makes test program in environment variable G4TARGET.
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
ifndef G4TARGET
|
||||
G4TARGET := $(TESTTARGET)
|
||||
endif
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../../..
|
||||
endif
|
||||
|
||||
G4EXEC_BUILD = true
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
# Override some variables for binmake.gmk.
|
||||
#
|
||||
INCFLAGS := -I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include
|
||||
LDLIBS := -lG4global
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
+131
-19
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.15 1999/06/21 09:11:14 allison Exp $
|
||||
$Id: History,v 1.35 1999/11/29 10:17:34 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,17 +17,129 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
June 21st J.Allison (global-01-00-05)
|
||||
November 29, 99 G.Cosmo (global-V00-01-14)
|
||||
- Removed g4std/string wrapper since not anymore needed.
|
||||
It was previously made available only for Win/NT-VC++.
|
||||
Inclusion of system <string> is handled only in g4rw/cstring where
|
||||
G4String is defined.
|
||||
|
||||
November 26, 99 G.Cosmo (global-V00-01-13)
|
||||
- STLInterface: backed up inline keyword for simple methods in
|
||||
vectors' classes (test comparison with previous tag).
|
||||
- Reorganised cstring[.h.icc], no functional changes.
|
||||
|
||||
November 25, 99 G.Cosmo (global-V00-01-12)
|
||||
- STLInterface: changes for ISO/ANSI C++ support:
|
||||
o Reorganised method definitions on wrapper classes; made templated
|
||||
vectors' methods all not inlined (test). Created .icc files accordingly.
|
||||
o Changed #define to typedef for std_string and protected in class
|
||||
scope. Introduced std_vector and std_pvector for collections,
|
||||
replaced G4std::vector<T> and G4std::vector<T*> accordingly.
|
||||
- Added default comment header to files in STLInterface and class
|
||||
descriptions for Software Reference Manual.
|
||||
|
||||
November 23, 99 G.Cosmo (global-V00-01-11)
|
||||
- Introduced changes to support ISO/ANSI code:
|
||||
o Modified STLInterface wrappers to invoke STL containers from G4std
|
||||
namespace.
|
||||
o Modified #include statements to invoke g4std wrappers.
|
||||
o Introduced G4endl and G4cin in G4ios.hh. Modified code accordingly.
|
||||
- Made destructors for vector wrappers collections in STLInterface virtual.
|
||||
- Added comments to G4UserLimits.hh for the Software Reference Manual
|
||||
(by M.Maire).
|
||||
|
||||
November 19, 99 G.Cosmo (global-V00-01-10)
|
||||
- Addition of comments for the Software Reference Manual (by M.Maire):
|
||||
G4UnitsTable.hh, G4UnitsTest.hh, PhysicalConstants.h, SystemOfUnits.h.
|
||||
|
||||
November 16, 99 G.Cosmo (global-V00-01-09)
|
||||
- STLInterface: removed wrappers for Dictionaries.
|
||||
Removed files: tvhdict.h, tphdict.h, rwstlhash.h.
|
||||
Removed also hash_map wrappers for every system.
|
||||
- Removed temporary 'using' statements in g4std wrappers.
|
||||
- Reorganised inline function definitions in management/include:
|
||||
added G4PhysicsVector.icc, G4LPhysicsFreeVector.icc and
|
||||
G4PhysicsOrderedFreeVector.icc.
|
||||
- Fixed bug G4PhysicsVector. Initialised data members in default constructor.
|
||||
- Removed 'RD44' from header description in every file.
|
||||
- Modifications for Software Reference Manual for existing class descriptions.
|
||||
|
||||
November 15, 99 G.Cosmo (global-V00-01-08)
|
||||
- Fixes for keywords which did not migrate by mistake in the conversion
|
||||
of the HEAD. Namely: RWDEFAULT_CAPACITY, RWBoundsErr, RWGeneralException,
|
||||
RWTHROW, RW2STL_LessPtr and in some cases RWCString.
|
||||
|
||||
November 11, 99 G.Cosmo (global-V00-01-07)
|
||||
- Migration RWT->G4RWT performed:
|
||||
o Moved STLInterface wrapper classes to STLinterface/g4rw.
|
||||
o Renamed RWCString to G4String and removed related typedef.
|
||||
o Removed RW_NPOS from defs.h and renamed other RW types/constants
|
||||
according to the migration.
|
||||
|
||||
November 10, 99 G.Cosmo (global-V00-01-06)
|
||||
- Temporarly redefined RW_NPOS in STLInterface/rw/defs.h.
|
||||
Will be removed in the RWT->G4RWT migration and replaced with
|
||||
G4std::string::npos directly in the code.
|
||||
|
||||
November 09, 99 G.Cosmo (global-V00-01-05)
|
||||
- Added new signature HashDefault(const unsigned long&) in STLInterface
|
||||
rw/rwstlhash.h.
|
||||
|
||||
October 28, 99 G.Cosmo (global-V00-01-04)
|
||||
- Removed G4STREAM implementation from G4ios and G4strstreambuf, no longer
|
||||
needed. Incremented buffer size to 4096 chars. (by H.Yoshida)
|
||||
|
||||
October 22, 99 G.Cosmo (global-V00-01-03)
|
||||
- Added first implementation of wrapper files for ISO-ANSI migration:
|
||||
added new directory management/include/g4std.
|
||||
- Added definition of G4std keyword in G4Types.hh.
|
||||
|
||||
October 20, 99 G.Cosmo (global-V00-01-02)
|
||||
- Tagged.
|
||||
|
||||
October 20, 99 J.Allison
|
||||
- STLInterface: cstring.h: changed (*this)[i] to std_string::operator[](i).
|
||||
- STLInterface: removed G4USE_EXPLICIT_TYPES_IN_TEMPLATES; introduced
|
||||
typename keyword where needed for HP aCC. Files modified:
|
||||
cstring.h, tpordvec.h, tpsrtvec.h, tpvector.h, tvhdict.h, tvordvec.h
|
||||
and tvvector.h.
|
||||
|
||||
October 6, 99 G.Cosmo (global-V00-01-01)
|
||||
- STLInterface: Changed tolower/toupper to old implementation in cstring.h
|
||||
(by F.Behner)
|
||||
|
||||
September 14, 99 G.Cosmo
|
||||
- STLInterface: renamed classes HashPtr and Hash to G4HashPtr and G4Hash in
|
||||
tphdict and tvhdict to make them compliant with G4 coding standards and
|
||||
avoid clashes with external software in global scope.
|
||||
- STLInterface: removed useless tests over size_t < 0 in files tvordvec.h,
|
||||
tvvector.h, tpsrtvec.h and tpordvec.h.
|
||||
- STLInterface: casted pointers to long in rwstlhash.h instead of unsigned.
|
||||
|
||||
September 13, 99 V.Grichine
|
||||
- Added new class G4Integrator (.hh/.icc) and test file
|
||||
G4IntegratorTest.cc in HEPNumerics for integration of generic
|
||||
functions.
|
||||
|
||||
September 10, 99 G.Cosmo
|
||||
- Added inline keyword to G4Poisson function in HEPRandom/include
|
||||
which was missing.
|
||||
|
||||
August 24, 99 J.Allison (global-V00-01-00)
|
||||
- Initialised pointer in first constructor of G4DataInterpolation.
|
||||
- Included STLInterface-V00-01-00.
|
||||
|
||||
June 21, 99 J.Allison (global-01-00-05)
|
||||
- Changed G4Exception to abort, i.e., produce core dump.
|
||||
- Includes STLInterface-18.
|
||||
|
||||
May 24th G.Cosmo (global-01-00-04)
|
||||
May 24, 99 G.Cosmo (global-01-00-04)
|
||||
- globals.hh: removed inclusion of G4Timer.hh, left only G4Types.hh.
|
||||
The attempted solution does not work in situation where STL headers are pulled
|
||||
in before globals.hh. Several of this cases experienced on HP-aCC.
|
||||
- STLInterface/rw/tphdict.h: added find() method to retrieve a key.
|
||||
|
||||
May 24th G.Cosmo (global-01-00-03)
|
||||
May 24, 99 G.Cosmo (global-01-00-03)
|
||||
- G4Timer.hh: removed CPP cludge for the "times" clash in ObjectSpace.
|
||||
Removed direct inclusion of global.hh to decouple translation unit from
|
||||
RW/STL headers. (F.Benher)
|
||||
@@ -36,50 +148,50 @@ May 24th G.Cosmo (global-01-00-03)
|
||||
- Added inclusion of G4Timer.hh in globals.hh to get rid of clashes about the
|
||||
order of inclusion. G4Timer.hh must appear -before- STL's <algorithm>.
|
||||
|
||||
May 19th G.Cosmo (global-01-00-02)
|
||||
May 19, 99 G.Cosmo (global-01-00-02)
|
||||
- templates.hh: added definition of DBL_EPSILON and FLT_EPSILON.
|
||||
Added 'F' to single precision literal constants.
|
||||
- Updates to STLInterface wrappers from the STL task-force. Added
|
||||
AIX-xlC STL wrappers.
|
||||
|
||||
May 17th J.Allison
|
||||
May 17, 99 J.Allison
|
||||
- Added #undef os_times in G4Timer.hh to avoid clash with ObjectSpace when
|
||||
using STLInterface on Sun.
|
||||
|
||||
May 14th G.Cosmo (global-01-00-01)
|
||||
May 14, 99 G.Cosmo (global-01-00-01)
|
||||
- Still updates to STLInterface from the STL task-force (internal tag considered
|
||||
is STLInterface-04). Introduced wrapper files differentiated for each architecture.
|
||||
|
||||
May 11th G.Cosmo
|
||||
May 11, 99 G.Cosmo
|
||||
- Updates and fixes to STLInterface headers. Input mainly from DEC and HP.
|
||||
- Added G4Poisson.hh to HEPRandom/include. It includes the implementation
|
||||
of the global function "G4long G4Poisson(G4double)" which reproduces the
|
||||
GPOISS algorithm adopted in Geant3. Uses the CLHEP standard engines as
|
||||
basic random generators.
|
||||
|
||||
May 3rd G.Cosmo (global-01-00-00)
|
||||
May 3, 99 G.Cosmo (global-01-00-00)
|
||||
- Updates to STL interface ISO/ANSI headers (F.Benher)
|
||||
- Added G4Exception call with STL strings in globals.hh and G4Exception.cc (F.Benher)
|
||||
|
||||
April 29th G.Cosmo
|
||||
April 29, 99 G.Cosmo
|
||||
- Moved SystemOfUnits.SI.h to G4UnitsTest.hh in management/include. This file is
|
||||
used only for test purposes and will not be tagged for public versions.
|
||||
|
||||
March 30th M.Maire
|
||||
March 30, 99 M.Maire
|
||||
- CodeWizard cleanup in G4UnitsTable. Fixed definition of operator=.
|
||||
|
||||
March 18th J.Allison
|
||||
March 18, 99 J.Allison
|
||||
- globals.hh: Added #ifdef G4USE_STL, changed position of
|
||||
#include <rw/cstring.h>.
|
||||
#include "g4rw/cstring.h".
|
||||
|
||||
December 17th 1998 J.Allison (global-00-04-03)
|
||||
December 17, 98 J.Allison (global-00-04-03)
|
||||
- Added first version of STL interface.
|
||||
|
||||
December 2, 1998 M.Asai (global-00-04-02)
|
||||
December 2, 98 M.Asai (global-00-04-02)
|
||||
- Remove the construction of G4UnitsMessenger in G4UnitsTable. This messenger is
|
||||
constructed/destructed by G4UImanager to avoid a loop dependency.
|
||||
|
||||
December 1, 1998 G.Cosmo (global-00-04-01)
|
||||
December 1, 98 G.Cosmo (global-00-04-01)
|
||||
- Removed G4Allocator.cc containing all template declarations for GNU-g++
|
||||
compiler not supported anymore.
|
||||
- Removed g4templates.hh contining all template declarations for the old
|
||||
@@ -89,7 +201,7 @@ December 1, 1998 G.Cosmo (global-00-04-01)
|
||||
- Updated management/GNUmakefile: not anymore dependencies over external
|
||||
categories. Dependency over intercoms to be fixed still.
|
||||
|
||||
December 1, 1998 M.Nagamatu, H Yoshida
|
||||
December 1, 98 M.Nagamatu, H Yoshida
|
||||
- G4ios.cc guarded by G4STREAM
|
||||
|
||||
November 27, 98 M.Asai
|
||||
@@ -163,8 +275,8 @@ July 14, 98 G.Cosmo (global-00-01-05)
|
||||
(H.Kurasige)
|
||||
|
||||
July 8, 98 G.Cosmo (global-00-01-04)
|
||||
- Removed forward declarations of RWTPtrOrderedVector<G4KineticTrack>
|
||||
and RWTPtrSortedVector<G4CollisionInitialState> from g4templates.hh.
|
||||
- Removed forward declarations of G4RWTPtrOrderedVector<G4KineticTrack>
|
||||
and G4RWTPtrSortedVector<G4CollisionInitialState> from g4templates.hh.
|
||||
|
||||
July 7, 98 G.Cosmo (global-00-01-03)
|
||||
- Removed old unit symbols in globals.hh (M.Maire)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.8 1999/07/06 15:02:39 gunter Exp $
|
||||
$Id: History,v 1.16 1999/11/29 10:17:36 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -21,6 +21,48 @@ committal in the CVS repository !
|
||||
STL Interface
|
||||
-------------
|
||||
|
||||
November 29, 99 G.Cosmo
|
||||
- Removed references to g4std/string, now removed since not anymore
|
||||
needed.
|
||||
|
||||
November 26, 99 G.Cosmo (STLInterface-V00-01-04)
|
||||
- Backed up inline keyword for simple methods in vectors' classes
|
||||
(test comparison with previous tag).
|
||||
- Reorganised cstring[.h.icc], no functional changes.
|
||||
|
||||
November 25, 99 G.Cosmo (STLInterface-V00-01-03)
|
||||
- STLInterface: changes for ISO/ANSI C++ support:
|
||||
o Reorganised method definitions on wrapper classes; made templated
|
||||
vectors' methods all not inlined (test). Created .icc files accordingly.
|
||||
o Changed #define to typedef for std_string and protected in class
|
||||
scope. Introduced std_vector and std_pvector for collections,
|
||||
replaced G4std::vector<T> and G4std::vector<T*> accordingly.
|
||||
- Added default comment header to files in STLInterface and class
|
||||
descriptions for Software Reference Manual.
|
||||
|
||||
November 23, 99 G.Cosmo
|
||||
- Introduced changes to support ISO/ANSI code:
|
||||
o Modified STLInterface wrappers to invoke STL containers from G4std
|
||||
namespace.
|
||||
o Modified #include statements to invoke g4std wrappers.
|
||||
o Introduced G4endl and G4cin in G4ios.hh. Modified code accordingly.
|
||||
- Made destructors for vector wrappers collections in STLInterface virtual.
|
||||
|
||||
16th November 1999 Gabriele Cosmo (STLInterface-V00-01-02)
|
||||
- Includes global migration RWT->G4RWT:
|
||||
o Moved all wrapper files from STLInterface/rw to STLInterface/g4rw.
|
||||
o Changed RW to G4RW everywhere, except: RWBoolean to G4Bool,
|
||||
RWCString to G4String, RWTokenizer to G4Tokenizer.
|
||||
o Removed definition of RW_NPOS from defs.h.
|
||||
- Removed wrappers for Dictionaries: tvhdict.h, tphdict.h, rwstlhash.h.
|
||||
Removed also hash_map wrappers.
|
||||
|
||||
6th October 1999 Frank Behner (STLInterface-V00-01-01)
|
||||
- Changed tolower/toupper to old implementation in cstring.h.
|
||||
|
||||
4th August 1999 Frank Behner (STLInterface-V00-01-00)
|
||||
- Implementation of RWCString::hash(const RWCString&).
|
||||
|
||||
6th July 1999 Gunter Folger
|
||||
- name for hash_map for WIN32 is hashmap.h ONLY with Object space;
|
||||
other implementations on WIN32 should use hash_map.h
|
||||
@@ -39,12 +81,12 @@ committal in the CVS repository !
|
||||
- Tagged Frank's fixes to tpordvec re insertAt(0,...) and similar.
|
||||
|
||||
20th June 1999 John Allison (STLInterface-18)
|
||||
- Removed RWTPtrHashDictionary(size_t n):fhm(n){}.
|
||||
- Implemented RWTPtrHashDictionary::clearAndDestroy of values *and*
|
||||
- Removed G4RWTPtrHashDictionary(size_t n):fhm(n){}.
|
||||
- Implemented G4RWTPtrHashDictionary::clearAndDestroy of values *and*
|
||||
keys, protecting against duplicate entries.
|
||||
- Reimplemented RWTPtrOrderedVector::clearAndDestroy with vector<T*>
|
||||
- Reimplemented G4RWTPtrOrderedVector::clearAndDestroy with vector<T*>
|
||||
instead of set<T*>.
|
||||
- Prevented RWTPtrOrderedVector::resize and RWTValOrderedVector::resize
|
||||
- Prevented G4RWTPtrOrderedVector::resize and G4RWTValOrderedVector::resize
|
||||
from reducing the size below the number if items.
|
||||
|
||||
20th June 1999 John Allison
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
// 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: cstring.h,v 1.6 1999/11/29 10:17:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4String
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Definition of a Geant4 string.
|
||||
// It's currently implemented as an STL wrapper class for Strings.
|
||||
// It implements Rogue Wave RWCString signature but intrinsically
|
||||
// using STL string.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __cstring
|
||||
#define __cstring
|
||||
|
||||
#include <string>
|
||||
#include "G4Types.hh"
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
#ifdef __KCC
|
||||
#include <istream>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
class G4String;
|
||||
|
||||
class G4SubString
|
||||
{
|
||||
public:
|
||||
|
||||
inline G4SubString(const G4SubString&);
|
||||
|
||||
inline G4SubString& operator=(const char*);
|
||||
|
||||
inline G4SubString& operator=(const G4String&);
|
||||
inline G4SubString& operator=(const G4SubString&);
|
||||
|
||||
inline char& operator()(size_t);
|
||||
inline char operator()(size_t) const;
|
||||
inline char& operator[](size_t);
|
||||
inline char operator[](size_t) const;
|
||||
|
||||
inline int operator!() const;
|
||||
|
||||
inline G4bool operator==(G4String) const;
|
||||
inline G4bool operator==(const char*) const;
|
||||
inline G4bool operator!=(G4String) const;
|
||||
inline G4bool operator!=(const char*) const;
|
||||
|
||||
inline size_t length() const;
|
||||
inline size_t start() const;
|
||||
|
||||
// For detecting null substrings
|
||||
//
|
||||
inline G4bool isNull() const;
|
||||
|
||||
private:
|
||||
|
||||
inline G4SubString(G4String&, size_t, size_t);
|
||||
|
||||
G4String* mystring;
|
||||
size_t mystart;
|
||||
size_t extent;
|
||||
|
||||
friend class G4String;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class G4String : public G4std::string
|
||||
{
|
||||
|
||||
typedef G4std::string std_string;
|
||||
|
||||
public:
|
||||
|
||||
enum caseCompare { exact, ignoreCase };
|
||||
enum stripType { leading, trailing, both };
|
||||
|
||||
inline G4String ();
|
||||
inline G4String ( char );
|
||||
inline G4String ( const char * );
|
||||
inline G4String ( const G4String& );
|
||||
inline G4String ( const G4SubString& );
|
||||
inline G4String ( const std_string& );
|
||||
virtual ~G4String () {}
|
||||
|
||||
inline G4String& operator=(const G4String&);
|
||||
inline G4String& operator=(const std_string&);
|
||||
inline G4String& operator=(const char*);
|
||||
|
||||
inline char operator () (size_t) const;
|
||||
inline char& operator () (size_t);
|
||||
|
||||
inline G4String& operator+=(const G4SubString&);
|
||||
inline G4String& operator+=(const char*);
|
||||
inline G4String& operator+=(const std_string&);
|
||||
inline G4String& operator+=(const char&);
|
||||
inline G4bool operator==(const G4String&) const;
|
||||
inline G4bool operator==(const char*) const;
|
||||
inline G4bool operator!=(const G4String&) const;
|
||||
inline G4bool operator!=(const char*) const;
|
||||
|
||||
//inline G4String operator () (unsigned int, unsigned int);
|
||||
inline operator const char*() const;
|
||||
inline G4SubString operator()(size_t, size_t);
|
||||
|
||||
inline int compareTo(const char*, caseCompare mode=exact);
|
||||
inline int compareTo(const G4String&, caseCompare mode=exact);
|
||||
|
||||
inline G4String& prepend (const char*);
|
||||
inline G4String& append (const G4String&);
|
||||
|
||||
inline G4std::istream& readLine (G4std::istream&, G4bool skipWhite=true);
|
||||
|
||||
inline G4String& replace (unsigned int, unsigned int,
|
||||
const char*, unsigned int );
|
||||
inline G4String& replace(size_t, size_t, const char*);
|
||||
|
||||
inline G4String& remove(size_t);
|
||||
inline G4String& remove(size_t, size_t);
|
||||
|
||||
inline int first(char) const;
|
||||
inline int last(char) const;
|
||||
|
||||
inline G4bool contains(std_string) const;
|
||||
inline G4bool contains(char) const;
|
||||
|
||||
// stripType = 0 beginning
|
||||
// stripType = 1 end
|
||||
// stripType = 2 both
|
||||
//
|
||||
inline G4String strip (int stripType=trailing, char c=' ');
|
||||
|
||||
inline void toLower ( void );
|
||||
inline void toUpper ( void );
|
||||
|
||||
inline G4bool isNull() const;
|
||||
|
||||
inline size_t index (const char*, int pos=0) const;
|
||||
inline size_t index (char, int pos=0) const;
|
||||
inline size_t index (const G4String&, size_t, size_t, caseCompare) const;
|
||||
|
||||
inline const char* data() const;
|
||||
|
||||
inline unsigned int hash( caseCompare cmp = exact ) const;
|
||||
inline unsigned int stlhash() const;
|
||||
|
||||
// useful for supplying hash functions to template hash collection ctors
|
||||
//
|
||||
static inline unsigned hash(const G4String&);
|
||||
|
||||
};
|
||||
|
||||
#include "g4rw/cstring.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,440 @@
|
||||
// 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: cstring.icc,v 1.2 1999/11/26 17:17:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// G4String
|
||||
//---------------------------------------------------------------
|
||||
|
||||
// **************************************************************
|
||||
// G4SubString
|
||||
// **************************************************************
|
||||
|
||||
G4SubString::G4SubString(const G4SubString&s)
|
||||
{
|
||||
mystring=s.mystring;
|
||||
mystart=s.mystart;
|
||||
extent=s.extent;
|
||||
}
|
||||
|
||||
G4SubString::G4SubString(G4String& str, size_t s, size_t e)
|
||||
: mystring(&str),mystart(s),extent(e)
|
||||
{
|
||||
}
|
||||
|
||||
G4SubString& G4SubString::operator=(const G4String&s)
|
||||
{
|
||||
G4String str(s);
|
||||
return operator=(str);
|
||||
}
|
||||
|
||||
G4SubString& G4SubString::operator=(const G4SubString&s)
|
||||
{
|
||||
mystring->replace(mystart,extent,s.mystring->data(),s.length());
|
||||
extent=s.length();
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4SubString& G4SubString::operator=(const char*s)
|
||||
{
|
||||
mystring->replace(mystart,extent,s,strlen(s));
|
||||
extent=strlen(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
char& G4SubString::operator()(size_t i)
|
||||
{
|
||||
return mystring->operator[](mystart+i);
|
||||
}
|
||||
|
||||
char G4SubString::operator()(size_t i) const
|
||||
{
|
||||
return mystring->operator[](mystart+i);
|
||||
}
|
||||
|
||||
char& G4SubString::operator[](size_t i)
|
||||
{
|
||||
return mystring->operator[](mystart+i);
|
||||
}
|
||||
|
||||
char G4SubString::operator[](size_t i) const
|
||||
{
|
||||
return mystring->operator[](mystart+i);
|
||||
}
|
||||
|
||||
int G4SubString::operator!() const
|
||||
{
|
||||
return extent==0 ? 1 : 0;
|
||||
}
|
||||
|
||||
G4bool G4SubString::operator==(G4String s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent) == s ? true:false;
|
||||
}
|
||||
|
||||
G4bool G4SubString::operator==(const char* s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent) == G4std::string(s) ? true:false;
|
||||
}
|
||||
|
||||
G4bool G4SubString::operator!=(G4String s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent) != G4std::string(s) ? true:false;
|
||||
}
|
||||
|
||||
G4bool G4SubString::operator!=(const char* s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent) != G4std::string(s) ? true:false;
|
||||
}
|
||||
|
||||
size_t G4SubString::length() const
|
||||
{
|
||||
return extent;
|
||||
}
|
||||
|
||||
size_t G4SubString::start() const
|
||||
{
|
||||
return mystart;
|
||||
}
|
||||
|
||||
G4bool G4SubString::isNull() const
|
||||
{
|
||||
return extent==0 ? true : false;
|
||||
}
|
||||
|
||||
// **************************************************************
|
||||
// G4String
|
||||
// **************************************************************
|
||||
|
||||
G4String::G4String () {}
|
||||
|
||||
G4String::G4String ( const char * astring )
|
||||
: std_string ( astring ) {}
|
||||
|
||||
G4String::G4String ( char c )
|
||||
{
|
||||
char str[2];
|
||||
str[0]=c;
|
||||
str[1]='\0';
|
||||
std_string::operator=(str);
|
||||
}
|
||||
|
||||
G4String::G4String ( const G4String& s )
|
||||
: std_string(s) {}
|
||||
|
||||
G4String::G4String ( const G4SubString& s )
|
||||
: std_string(*(s.mystring),s.mystart,s.extent) {}
|
||||
|
||||
G4String::G4String ( const std_string& s )
|
||||
: std_string(s) {}
|
||||
|
||||
G4String& G4String::operator=(const G4String& s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::operator=(const std_string& s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::operator=(const char* s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// "cmp" optional parameter is NOT implemented !
|
||||
// N.B.: The hash value returned is generally DIFFERENT from the
|
||||
// one returned by the original RW function.
|
||||
// Users should not rely on the specific return value.
|
||||
//
|
||||
char G4String::operator () (size_t i) const
|
||||
{
|
||||
return operator[](i);
|
||||
}
|
||||
|
||||
char& G4String::operator () (size_t i)
|
||||
{
|
||||
return std_string::operator[](i);
|
||||
}
|
||||
|
||||
G4String& G4String::operator+=(const G4SubString&s)
|
||||
{
|
||||
G4String tmp(s);
|
||||
std_string::operator+=(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::operator+=(const char*s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::operator+=(const std_string &s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::operator+=(const char &c)
|
||||
{
|
||||
std_string::operator+=(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4bool G4String::operator==(const G4String &s) const
|
||||
{
|
||||
const std_string *a=this;
|
||||
const std_string *b=&s;
|
||||
return *a==*b;
|
||||
}
|
||||
|
||||
G4bool G4String::operator==(const char* s) const
|
||||
{
|
||||
const std_string *a=this;
|
||||
const std_string b=s;
|
||||
return *a==b;
|
||||
}
|
||||
|
||||
G4bool G4String::operator!=(const G4String &s) const
|
||||
{
|
||||
const std_string *a=this;
|
||||
const std_string *b=&s;
|
||||
return *a!=*b;
|
||||
}
|
||||
|
||||
G4bool G4String::operator!=(const char* s) const
|
||||
{
|
||||
const std_string *a=this;
|
||||
const std_string b=s;
|
||||
return *a!=b;
|
||||
}
|
||||
|
||||
G4String::operator const char*() const
|
||||
{
|
||||
return c_str();
|
||||
}
|
||||
|
||||
int G4String::compareTo(const char* s, caseCompare mode)
|
||||
{
|
||||
//GB:OSF1-cxx if(mode=exact)
|
||||
if(mode==exact)
|
||||
return strcmp(c_str(),s);
|
||||
else
|
||||
return strcasecmp(c_str(),s);
|
||||
}
|
||||
|
||||
int G4String::compareTo(const G4String& s, caseCompare mode)
|
||||
{
|
||||
//GB:OSF1-cxx if(mode=exact)
|
||||
if(mode==exact)
|
||||
return strcmp(data(),s.data());
|
||||
else
|
||||
return strcasecmp(data(),s.data());
|
||||
}
|
||||
|
||||
G4String& G4String::prepend (const char* str)
|
||||
{
|
||||
insert(0,str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::append(const G4String& s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4std::istream&
|
||||
G4String::readLine (G4std::istream& s, G4bool skipWhite)
|
||||
{
|
||||
char tmp[256];
|
||||
if ( skipWhite ) {
|
||||
s >> G4std::ws;
|
||||
s.getline(tmp,256);
|
||||
*this=tmp;
|
||||
}
|
||||
else {
|
||||
s.getline(tmp,256);
|
||||
*this=tmp;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
G4String& G4String::replace (unsigned int start, unsigned int nbytes,
|
||||
const char* buff, unsigned int n2 )
|
||||
{
|
||||
std_string::replace ( start, nbytes, buff, n2 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::replace(size_t pos, size_t n, const char* s)
|
||||
{
|
||||
std_string::replace(pos,n,s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::remove(size_t n)
|
||||
{
|
||||
if(n<size())
|
||||
erase(n,size()-n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String& G4String::remove(size_t pos, size_t N)
|
||||
{
|
||||
erase(pos,N+pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int G4String::first(char c) const
|
||||
{
|
||||
return find(c);
|
||||
}
|
||||
|
||||
int G4String::last(char c) const
|
||||
{
|
||||
return rfind(c);
|
||||
}
|
||||
|
||||
G4bool G4String::contains(std_string s) const
|
||||
{
|
||||
int i=find(s);
|
||||
if(i != std_string::npos)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
G4bool G4String::contains(char c) const
|
||||
{
|
||||
int i=find(c);
|
||||
if(i != std_string::npos)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
G4String G4String::strip (int stripType, char c)
|
||||
{
|
||||
G4String retVal = *this;
|
||||
if(length()==0) return retVal;
|
||||
int i;
|
||||
switch ( stripType ) {
|
||||
case leading:
|
||||
{
|
||||
for(i=0;i<length();i++)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
retVal = substr(i,length()-i);
|
||||
}
|
||||
break;
|
||||
case trailing:
|
||||
{
|
||||
for(i=length()-1;i>=0;i--)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
retVal = substr(0,i+1);
|
||||
}
|
||||
break;
|
||||
case both:
|
||||
{
|
||||
for(i=0;i<length();i++)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
G4String tmp(substr(i,length()-i));
|
||||
for(i=tmp.length()-1;i>=0;i--)
|
||||
if (tmp.std_string::operator[](i) != c) break;
|
||||
retVal = tmp.substr(0,i+1);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void G4String::toLower ( void )
|
||||
{
|
||||
for (int i=0; i<=size();i++)
|
||||
{
|
||||
//GB:HP-UX-aCC,Linux-KCC
|
||||
std_string::operator[](i) = tolower(std_string::operator[](i));
|
||||
//at(i) = tolower(at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void G4String::toUpper ( void )
|
||||
{
|
||||
for (int i=0; i<=size();i++)
|
||||
{
|
||||
//GB:HP-UX-aCC,Linux-KCC
|
||||
std_string::operator[](i) = tolower(std_string::operator[](i));
|
||||
//at(i) = toupper(at(i));
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4String::isNull() const
|
||||
{
|
||||
return empty ();
|
||||
}
|
||||
|
||||
// "cs" optional parameter is NOT implemented !
|
||||
//
|
||||
size_t G4String::index( const G4String& s, size_t ln,
|
||||
size_t st, G4String::caseCompare cs ) const
|
||||
{
|
||||
return std_string::find( s.c_str(), st, ln );
|
||||
}
|
||||
|
||||
size_t G4String::index (const char* str, int pos) const
|
||||
{
|
||||
return std_string::find(str,pos);
|
||||
}
|
||||
|
||||
size_t G4String::index (char c, int pos) const
|
||||
{
|
||||
return std_string::find(c,pos);
|
||||
}
|
||||
|
||||
G4SubString G4String::operator()(size_t start, size_t extent)
|
||||
{
|
||||
return G4SubString(*this,start,extent);
|
||||
}
|
||||
|
||||
const char* G4String::data() const
|
||||
{
|
||||
return c_str();
|
||||
}
|
||||
|
||||
unsigned int G4String::hash( caseCompare cmp ) const
|
||||
{
|
||||
const char*s=c_str();
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
|
||||
unsigned int G4String::stlhash() const
|
||||
{
|
||||
const char*s=c_str();
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
|
||||
unsigned G4String::hash(const G4String& s)
|
||||
{
|
||||
return s.hash();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// 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: ctoken.h,v 1.5 1999/11/29 10:17:41 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4Tokenizer
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for String tokenizer.
|
||||
// It implements Rogue Wave RWTokenizer signature but
|
||||
// intrinsically using STL string.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __ctoken
|
||||
#define __ctoken
|
||||
|
||||
#include "g4rw/defs.h"
|
||||
#include "g4rw/cstring.h"
|
||||
|
||||
class G4Tokenizer
|
||||
{
|
||||
public:
|
||||
G4Tokenizer(const G4String& s):string2tokenize(s),actual(0){}
|
||||
|
||||
G4SubString operator()(const char* str=" \t\n",size_t l=0)
|
||||
{
|
||||
size_t i,j,tmp;
|
||||
G4bool hasws=false;
|
||||
if(l==0) l=strlen(str);
|
||||
//Skip leading delimeters
|
||||
while(actual<string2tokenize.size())
|
||||
{
|
||||
|
||||
for(i=0;i<l;i++)
|
||||
if(string2tokenize[actual]==str[i]) hasws=true;
|
||||
if(hasws)
|
||||
{
|
||||
actual++;
|
||||
hasws=false;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for(j=actual;j<string2tokenize.size();j++)
|
||||
{
|
||||
for(i=0;i<l;i++)
|
||||
if(string2tokenize[j]==str[i]) break;
|
||||
if(i<l) break;
|
||||
}
|
||||
if(j!=string2tokenize.size())
|
||||
{
|
||||
tmp=actual;
|
||||
actual=j+1;
|
||||
return string2tokenize(tmp,j-tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp=actual;
|
||||
actual=j;
|
||||
return string2tokenize(tmp,j-tmp);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
G4String string2tokenize;
|
||||
size_t actual;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
// 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: defs.h,v 1.7 1999/11/29 16:52:36 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWBoundsErr, G4RWGeneralException
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper classes for Errors and Exceptions utilities.
|
||||
// It implements Rogue Wave RWBoundsErr and RWGeneralException
|
||||
// signatures but intrinsically decoupled from Rogue Wave.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __defs
|
||||
#define __defs
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include "G4Types.hh"
|
||||
|
||||
#define G4RWDEFAULT_CAPACITY (64)
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define CLHEP_MAX_MIN_DEFINED
|
||||
#include <CLHEP/config/TemplateFunctions.h>
|
||||
|
||||
class G4RWBoundsErr
|
||||
{
|
||||
public:
|
||||
|
||||
G4RWBoundsErr(const char* s,int b=0,int v=0)
|
||||
{
|
||||
char btmp[80],vtmp[80];
|
||||
sprintf(btmp,"%d",b);
|
||||
sprintf(vtmp,"%d",v);
|
||||
str=new char[strlen(s)+8+strlen(btmp)+7+strlen(vtmp)+1];
|
||||
strcpy(str,s);
|
||||
strcat(str,": bound:");
|
||||
strcat(str,btmp);
|
||||
strcat(str," value:");
|
||||
strcat(str,vtmp);
|
||||
}
|
||||
|
||||
G4RWBoundsErr(const G4RWBoundsErr&e)
|
||||
{
|
||||
str=new char[strlen(e.str)+1];
|
||||
strcpy(str,e.str);
|
||||
}
|
||||
|
||||
~G4RWBoundsErr()
|
||||
{
|
||||
delete str;
|
||||
}
|
||||
|
||||
const char * why() const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
char* str;
|
||||
|
||||
};
|
||||
|
||||
class G4RWGeneralException
|
||||
{
|
||||
public:
|
||||
|
||||
G4RWGeneralException(const char* s)
|
||||
{
|
||||
str=new char[strlen(s)+1];
|
||||
strcpy(str,s);
|
||||
}
|
||||
|
||||
G4RWGeneralException(const G4RWGeneralException&e)
|
||||
{
|
||||
str=new char[strlen(e.str)+1];
|
||||
strcpy(str,e.str);
|
||||
}
|
||||
|
||||
~G4RWGeneralException()
|
||||
{
|
||||
delete str;
|
||||
}
|
||||
|
||||
const char * why() const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
char* str;
|
||||
|
||||
};
|
||||
|
||||
#define G4RWTHROW(a) throw a
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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: rstream.h,v 1.4 1999/11/25 10:14:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 utility file
|
||||
//
|
||||
// Definition of utility function rwEatwhite.
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __rstream
|
||||
#define __rstream
|
||||
|
||||
#include "g4rw/defs.h"
|
||||
#include "G4Types.hh"
|
||||
#include "g4std/iostream"
|
||||
|
||||
inline G4std::istream& rwEatwhite(G4std::istream& stream)
|
||||
{
|
||||
return stream >> G4std::ws;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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: rw2stl_algo.h,v 1.4 1999/11/25 10:14:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RW2STL_LessPtr
|
||||
//
|
||||
// STL wrapper utility class G4RW2STL_LessPtr.
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef rw2stl_algo_h
|
||||
#define rw2stl_algo_h
|
||||
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
template <class T>
|
||||
class G4RW2STL_LessPtr
|
||||
{
|
||||
public:
|
||||
|
||||
G4bool operator()(const T* a, const T* b) const
|
||||
{
|
||||
if(a==0) return false;
|
||||
if(b==0) return true;
|
||||
return *a<*b;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
// 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: tpordvec.h,v 1.7 1999/11/26 17:17:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTPtrOrderedVector
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for Pointer Ordered arrays. It implements
|
||||
// Rogue Wave RWTPtrOrderedVector signature but intrinsically
|
||||
// using STL vector.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __tpordvec
|
||||
#define __tpordvec
|
||||
|
||||
#include "g4std/vector"
|
||||
#include "g4std/set"
|
||||
#include "g4std/functional"
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
template<class T>
|
||||
class G4RWTPtrOrderedVector : public G4std::vector<T*>
|
||||
{
|
||||
typedef G4std::vector<T*> std_pvector;
|
||||
typedef typename std_pvector::iterator iterator;
|
||||
typedef typename std_pvector::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
|
||||
G4RWTPtrOrderedVector(size_t capacity=G4RWDEFAULT_CAPACITY);
|
||||
G4RWTPtrOrderedVector(const G4RWTPtrOrderedVector<T>&);
|
||||
virtual ~G4RWTPtrOrderedVector();
|
||||
|
||||
inline G4RWTPtrOrderedVector<T>& operator=(const G4RWTPtrOrderedVector<T>&);
|
||||
|
||||
inline T*& operator()(size_t);
|
||||
inline T* const& operator()(size_t) const;
|
||||
inline T*& operator[](size_t);
|
||||
inline T* const& operator[](size_t) const;
|
||||
|
||||
void clearAndDestroy();
|
||||
void clear();
|
||||
|
||||
size_t index (const T*) const;
|
||||
void resize (size_t);
|
||||
inline void insert (T*);
|
||||
void insertAt (size_t, T*);
|
||||
size_t occurrencesOf (const T*) const;
|
||||
|
||||
T* remove (const T*);
|
||||
size_t removeAll (const T*);
|
||||
T* removeAt (size_t);
|
||||
T* removeFirst ();
|
||||
T* removeLast ();
|
||||
|
||||
T* find (const T*) const;
|
||||
inline size_t entries() const;
|
||||
inline void append (T*);
|
||||
inline size_t length() const;
|
||||
inline T*& at (size_t);
|
||||
inline T*const& at (size_t) const;
|
||||
G4bool contains (const T*) const;
|
||||
inline G4bool isEmpty() const;
|
||||
|
||||
inline T* first() const;
|
||||
inline T* last() const;
|
||||
inline void prepend(T* const);
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
};
|
||||
|
||||
// Include actual implementations of templated class methods.
|
||||
|
||||
#include "g4rw/tpordvec.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,355 @@
|
||||
// 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: tpordvec.icc,v 1.1 1999/11/25 10:14:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// G4RWTPtrOrderedVector
|
||||
//---------------------------------------------------------------
|
||||
|
||||
template<class T >
|
||||
G4RWTPtrOrderedVector<T>::G4RWTPtrOrderedVector(size_t capacity)
|
||||
: std_pvector(capacity,(T*)0),rwsize(0){}
|
||||
|
||||
template<class T >
|
||||
G4RWTPtrOrderedVector<T>::G4RWTPtrOrderedVector(const G4RWTPtrOrderedVector<T>& v)
|
||||
: std_pvector(v),rwsize(v.rwsize){}
|
||||
|
||||
template<class T >
|
||||
G4RWTPtrOrderedVector<T>::~G4RWTPtrOrderedVector(){}
|
||||
|
||||
template<class T >
|
||||
G4RWTPtrOrderedVector<T>&
|
||||
G4RWTPtrOrderedVector<T>::operator=(const G4RWTPtrOrderedVector<T>& v)
|
||||
{
|
||||
std_pvector::operator=(v),
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T >
|
||||
T*& G4RWTPtrOrderedVector<T>::operator()(size_t i)
|
||||
{
|
||||
//if(i>=rwsize)
|
||||
// G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector ()",rwsize,i));
|
||||
if(i<std_pvector::size() && rwsize<=i) rwsize=i+1;
|
||||
return std_pvector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T >
|
||||
T* const& G4RWTPtrOrderedVector<T>::operator()(size_t i) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector const ()",rwsize,i));
|
||||
return std_pvector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T >
|
||||
T*& G4RWTPtrOrderedVector<T>::operator[](size_t i)
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector []",rwsize,i));
|
||||
//if(i<std_pvector::size() && rwsize<=i) rwsize=i+1;
|
||||
return std_pvector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T >
|
||||
T* const& G4RWTPtrOrderedVector<T>::operator[](size_t i) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector const []",rwsize,i));
|
||||
return std_pvector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T >
|
||||
void G4RWTPtrOrderedVector<T>::clear()
|
||||
{
|
||||
// std_pvector::erase(std_pvector::begin(), std_pvector::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T >
|
||||
void G4RWTPtrOrderedVector<T>::clearAndDestroy()
|
||||
{
|
||||
int sz;
|
||||
G4std::set<T*,G4std::greater<T*> > tmp;
|
||||
for (sz=0;sz<rwsize;sz++)
|
||||
{
|
||||
T* current;
|
||||
current=std_pvector::operator[](sz);
|
||||
if ( current )
|
||||
tmp.insert(current);
|
||||
}
|
||||
typename G4std::set<T*,G4std::greater<T*> >::iterator it;
|
||||
for(it=tmp.begin();it!=tmp.end();it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
// std_pvector::erase(std_pvector::begin(), std_pvector::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrOrderedVector<T>::index( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
for (i = std_pvector::begin();ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a) return ptn;
|
||||
}
|
||||
return (ptn=~(size_t)0);
|
||||
}
|
||||
|
||||
template<class T >
|
||||
void G4RWTPtrOrderedVector<T>::insert ( T* a )
|
||||
{
|
||||
if(rwsize<std_pvector::size())
|
||||
{
|
||||
std_pvector::operator[](rwsize)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
std_pvector::push_back(a);
|
||||
rwsize=std_pvector::size();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrOrderedVector<T>::occurrencesOf( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
for (i = std_pvector::begin();sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (**i==*a) ptn++;
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTPtrOrderedVector<T>::contains( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn=0;
|
||||
for (i = std_pvector::begin(); ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::remove( const T* a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = std_pvector::begin();ptn<rwsz; i++,ptn++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
T* tmp=*i;
|
||||
std_pvector::erase(i);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrOrderedVector<T>::removeAll( const T* a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = std_pvector::begin();sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
std_pvector::erase(i);
|
||||
rwsize--;
|
||||
i--;
|
||||
ptn++;
|
||||
}
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
// should throw exception if ...
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::removeAt( size_t i )
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector removeAt",rwsize,i));
|
||||
iterator it=std_pvector::begin();
|
||||
int j;
|
||||
for(j=0;j<rwsize && j<i;j++) it++;
|
||||
if(it!=std_pvector::end())
|
||||
{
|
||||
T* tmp = operator[](i);
|
||||
std_pvector::erase(it);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::find(const T* a) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn=0;
|
||||
for (i = std_pvector::begin(); ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrOrderedVector<T>::resize(size_t N)
|
||||
{
|
||||
if(N>std_pvector::size())
|
||||
{
|
||||
int e=N-std_pvector::size();
|
||||
for(int i=0;i<e;i++)
|
||||
std_pvector::push_back(0);
|
||||
}
|
||||
else if(N>rwsize)
|
||||
{
|
||||
iterator it=std_pvector::begin();
|
||||
for(int i=0;i<N;i++,it++);
|
||||
std_pvector::erase(it,std_pvector::end());
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrOrderedVector<T>::insertAt ( size_t i, T* a )
|
||||
{
|
||||
// insertAt throws an exception of type G4RWBoundsErr
|
||||
// if you try to insert out of range
|
||||
//
|
||||
if(i>rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector insertAt",rwsize,i));
|
||||
if(rwsize<std_pvector::size())
|
||||
{
|
||||
for(int j=rwsize;j>i;j--)
|
||||
std_pvector::operator[](j)=std_pvector::operator[](j-1);
|
||||
std_pvector::operator[](i)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=std_pvector::begin();
|
||||
for(int j=0;j<i;j++,it++);
|
||||
std_pvector::insert(it,a);
|
||||
rwsize++;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::removeFirst ()
|
||||
{
|
||||
if(rwsize!=0)
|
||||
{
|
||||
T* tmp=std_pvector::front();
|
||||
std_pvector::erase(std_pvector::begin());
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::removeLast ()
|
||||
{
|
||||
if(rwsize==0) return (T*) 0;
|
||||
|
||||
rwsize--;
|
||||
T* tmp=std_pvector::operator[](rwsize);
|
||||
std_pvector::operator[](rwsize)=0;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrOrderedVector<T>::entries() const
|
||||
{
|
||||
return rwsize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrOrderedVector<T>::append ( T* a )
|
||||
{
|
||||
insert( a );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrOrderedVector<T>::length() const
|
||||
{
|
||||
return rwsize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T*& G4RWTPtrOrderedVector<T>::at ( size_t i )
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector at",rwsize,i));
|
||||
return operator()(i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T*const& G4RWTPtrOrderedVector<T>::at ( size_t i ) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector const at",rwsize,i));
|
||||
return operator()(i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTPtrOrderedVector<T>::isEmpty() const
|
||||
{
|
||||
return rwsize==0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::first() const
|
||||
{
|
||||
if(!rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrOrderedVector front",rwsize,0));
|
||||
return std_pvector::front();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrOrderedVector<T>::last() const
|
||||
{
|
||||
if(rwsize)
|
||||
return std_pvector::operator[](rwsize-1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrOrderedVector<T>::prepend(T* const ptr)
|
||||
{
|
||||
std_pvector::insert(std_pvector::begin(),ptr);
|
||||
rwsize++;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// 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: tpsrtvec.h,v 1.8 1999/11/26 17:17:57 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTPtrSortedVector
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for Pointer Sorted arrays. It implements
|
||||
// Rogue Wave RWTPtrSortedVector signature but intrinsically
|
||||
// using STL vector.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __tpsrtvec
|
||||
#define __tpsrtvec
|
||||
|
||||
#include "g4rw/rw2stl_algo.h"
|
||||
#include "g4std/vector"
|
||||
#include "g4std/algorithm"
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
|
||||
template <class T>
|
||||
class G4RWTPtrSortedVector : public G4std::vector<T*>
|
||||
{
|
||||
|
||||
typedef G4std::vector<T*> std_pvector;
|
||||
typedef typename std_pvector::iterator iterator;
|
||||
typedef typename std_pvector::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
|
||||
G4RWTPtrSortedVector(size_t n=G4RWDEFAULT_CAPACITY);
|
||||
G4RWTPtrSortedVector(const G4RWTPtrSortedVector<T>&);
|
||||
virtual ~G4RWTPtrSortedVector();
|
||||
|
||||
inline G4RWTPtrSortedVector<T>& operator=(const G4RWTPtrSortedVector<T>&);
|
||||
|
||||
inline T* const& operator [] (size_t) const;
|
||||
inline T* const& operator () (size_t) const;
|
||||
|
||||
inline T*& at (size_t);
|
||||
inline T* at (size_t) const;
|
||||
|
||||
void clear();
|
||||
void clearAndDestroy ();
|
||||
|
||||
T* find (const T*) const;
|
||||
inline size_t entries () const;
|
||||
inline void insert (T*);
|
||||
size_t index (const T* a);
|
||||
inline G4bool isEmpty () const;
|
||||
|
||||
inline T* const & first () const;
|
||||
inline T* const & last () const;
|
||||
|
||||
size_t occurrencesOf(const T*) const;
|
||||
|
||||
T* remove (const T*);
|
||||
size_t removeAll (const T*);
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
G4RW2STL_LessPtr<T> sorter;
|
||||
|
||||
};
|
||||
|
||||
// Include actual implementations of templated class methods.
|
||||
|
||||
#include "g4rw/tpsrtvec.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,240 @@
|
||||
// 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: tpsrtvec.icc,v 1.2 1999/11/25 13:41:26 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// G4RWTPtrSortedVector
|
||||
//---------------------------------------------------------------
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrSortedVector<T>::G4RWTPtrSortedVector(size_t n)
|
||||
: std_pvector(n),rwsize(0)
|
||||
{
|
||||
for(int i=0;i<n;i++)
|
||||
std_pvector::operator[](i)=0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrSortedVector<T>::G4RWTPtrSortedVector(const G4RWTPtrSortedVector<T>& v)
|
||||
: std_pvector(v), rwsize(v.rwsize){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrSortedVector<T>::~G4RWTPtrSortedVector(){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrSortedVector<T>&
|
||||
G4RWTPtrSortedVector<T>::operator=(const G4RWTPtrSortedVector<T>& v)
|
||||
{
|
||||
std_pvector::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* const& G4RWTPtrSortedVector<T>::operator [] (size_t n) const
|
||||
{
|
||||
if(n>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrSortedVector",rwsize,n));
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* const& G4RWTPtrSortedVector<T>::operator () (size_t n) const
|
||||
{
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T*& G4RWTPtrSortedVector<T>::at(size_t n )
|
||||
{
|
||||
if(n>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrSortedVector",rwsize,n));
|
||||
if(n<std_pvector::size() && rwsize<=n)
|
||||
rwsize=n+1;
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrSortedVector<T>::at(size_t n ) const
|
||||
{
|
||||
if(n>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrSortedVector",rwsize,n));
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrSortedVector<T>::clear()
|
||||
{
|
||||
std_pvector::erase(std_pvector::begin(),std_pvector::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrSortedVector<T>::clearAndDestroy ()
|
||||
{
|
||||
size_t sz=0;
|
||||
for(iterator it=std_pvector::begin();sz<rwsize;it++,sz++)
|
||||
delete *it;
|
||||
std_pvector::erase(std_pvector::begin(),std_pvector::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrSortedVector<T>::find (const T* a) const
|
||||
{
|
||||
if(!a || std_pvector::empty()) return 0;
|
||||
//We are sorted, so try a n log n search
|
||||
int t,d;
|
||||
int u=rwsize,l=0;
|
||||
do
|
||||
{
|
||||
d=(u-l)/2;
|
||||
t=d+l;
|
||||
//this asks *a <= (*(*this)[t] whithout requiring operator<=
|
||||
if(sorter(a,(*this)[t]) || *a==*(*this)[t])
|
||||
u=t;
|
||||
else
|
||||
l=t;
|
||||
}
|
||||
while(d>0);
|
||||
|
||||
if(*(*this)[u]==*a)
|
||||
return (*this)[u];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrSortedVector<T>::entries () const
|
||||
{
|
||||
return rwsize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrSortedVector<T>::insert ( T* a )
|
||||
{
|
||||
if(rwsize<std_pvector::size())
|
||||
{
|
||||
//We have empty entries
|
||||
iterator it=std_pvector::begin();
|
||||
for(int i=0;i<rwsize;i++,it++);
|
||||
*it=a;
|
||||
it++;
|
||||
G4std::sort(std_pvector::begin(),it,sorter);
|
||||
}
|
||||
else
|
||||
{
|
||||
std_pvector::push_back(a);
|
||||
//This makes it a sorted thing;
|
||||
G4std::sort(std_pvector::begin(),std_pvector::end(),sorter);
|
||||
}
|
||||
rwsize++;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrSortedVector<T>::index ( const T* a )
|
||||
{
|
||||
T*const* ii = std_pvector::begin();
|
||||
size_t cnt = 0;
|
||||
for (T*const* it = ii;cnt<rwsize; ++it,cnt++)
|
||||
{
|
||||
if ( **it == *a ) return cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTPtrSortedVector<T>::isEmpty () const
|
||||
{
|
||||
return rwsize==0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* const & G4RWTPtrSortedVector<T>::first () const
|
||||
{
|
||||
if(!rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrSortedVector first()",rwsize,0));
|
||||
return std_pvector::front();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* const & G4RWTPtrSortedVector<T>::last () const
|
||||
{
|
||||
if(rwsize)
|
||||
return std_pvector::operator[](rwsize-1);
|
||||
else
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTPtrSortedVector last()",rwsize,0));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrSortedVector<T>::occurrencesOf(const T* a) const
|
||||
{
|
||||
size_t cnt = 0;
|
||||
size_t sz = 0;
|
||||
for (const_iterator it = std_pvector::begin();sz<rwsize; ++it,sz++)
|
||||
{
|
||||
if ( **it == *a ) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrSortedVector<T>::remove ( const T* a )
|
||||
{
|
||||
iterator retval;
|
||||
size_t sz=0;
|
||||
for(retval=std_pvector::begin();sz<rwsize;retval++,sz++)
|
||||
if(**retval==*a) break;
|
||||
if(sz<rwsize && retval!=std_pvector::end())
|
||||
{
|
||||
T* tmp=*retval;
|
||||
std_pvector::erase(retval);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrSortedVector<T>::removeAll ( const T* a)
|
||||
{
|
||||
iterator s=std_pvector::end();
|
||||
iterator e=std_pvector::end();
|
||||
iterator r;
|
||||
size_t sz=0;
|
||||
int i=0;
|
||||
for(r=std_pvector::begin();sz<rwsize;r++,sz++)
|
||||
{
|
||||
if(i==0)
|
||||
{
|
||||
if(**r==*a)
|
||||
{
|
||||
s=r;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(**r!=*a)
|
||||
{
|
||||
e=r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
std_pvector::erase(s,e);
|
||||
rwsize-=i;
|
||||
return i;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// 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: tpvector.h,v 1.7 1999/11/26 17:17:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTPtrVector
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for Pointer arrays. It implements
|
||||
// Rogue Wave RWTPtrVector signature but intrinsically
|
||||
// using STL vector.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __tpvector
|
||||
#define __tpvector
|
||||
|
||||
#include "g4std/vector"
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
template<class T>
|
||||
class G4RWTPtrVector : public G4std::vector<T*>
|
||||
{
|
||||
|
||||
typedef G4std::vector<T*> std_pvector;
|
||||
typedef typename std_pvector::iterator iterator;
|
||||
typedef typename std_pvector::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
|
||||
G4RWTPtrVector ();
|
||||
G4RWTPtrVector (unsigned int);
|
||||
G4RWTPtrVector (unsigned int, T* const &);
|
||||
G4RWTPtrVector (const G4RWTPtrVector<T>&);
|
||||
virtual ~G4RWTPtrVector();
|
||||
|
||||
G4RWTPtrVector<T>& operator = (T*);
|
||||
|
||||
inline T* operator () (size_t) const;
|
||||
inline T*& operator () (size_t);
|
||||
|
||||
inline T* operator [] (size_t) const;
|
||||
inline T*& operator [] (size_t);
|
||||
inline T* const * data() const;
|
||||
inline size_t length();
|
||||
inline void reshape(size_t);
|
||||
|
||||
};
|
||||
|
||||
// Include actual implementations of templated class methods.
|
||||
|
||||
#include "g4rw/tpvector.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
// 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: tpvector.icc,v 1.4 1999/11/25 10:14:46 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTPtrVector
|
||||
//---------------------------------------------------------------
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>::G4RWTPtrVector ()
|
||||
: std_pvector(){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>::G4RWTPtrVector (unsigned int n)
|
||||
: std_pvector(n){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>::G4RWTPtrVector (unsigned int n, T* const & iPtr)
|
||||
: std_pvector(n, iPtr){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>::G4RWTPtrVector (const G4RWTPtrVector<T>& iPtr)
|
||||
: std_pvector(iPtr){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>::~G4RWTPtrVector(){}
|
||||
|
||||
template<class T>
|
||||
G4RWTPtrVector<T>& G4RWTPtrVector<T>::operator = (T* p)
|
||||
{
|
||||
for(iterator i = std_pvector::begin(); i != std_pvector::end(); ++i)
|
||||
{
|
||||
*i = p;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* G4RWTPtrVector<T>::operator () ( size_t n ) const
|
||||
{
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T*& G4RWTPtrVector<T>::operator () ( size_t n )
|
||||
{
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
// The [] operator should perform bound checking
|
||||
//
|
||||
template<class T>
|
||||
T* G4RWTPtrVector<T>::operator [] ( size_t n ) const
|
||||
{
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T*& G4RWTPtrVector<T>::operator [] ( size_t n )
|
||||
{
|
||||
return std_pvector::operator[](n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* const * G4RWTPtrVector<T>::data() const
|
||||
{
|
||||
return &(std_pvector::front());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTPtrVector<T>::length()
|
||||
{
|
||||
return std_pvector::size();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTPtrVector<T>::reshape( size_t n )
|
||||
{
|
||||
std_pvector::resize(n);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// 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: tvordvec.h,v 1.7 1999/11/26 17:17:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTValOrderedVector
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for Value Ordered arrays. It implements
|
||||
// Rogue Wave RWTValOrderedVector signature but intrinsically
|
||||
// using STL vector.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __tvordvec
|
||||
#define __tvordvec
|
||||
|
||||
#include "g4std/vector"
|
||||
#include "g4std/algorithm"
|
||||
|
||||
#include "g4rw/defs.h"
|
||||
#include "g4rw/tvvector.h"
|
||||
|
||||
template<class T>
|
||||
class G4RWTValOrderedVector : public G4std::vector<T>
|
||||
{
|
||||
|
||||
typedef G4std::vector<T> std_vector;
|
||||
typedef typename std_vector::iterator iterator;
|
||||
typedef typename std_vector::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
|
||||
G4RWTValOrderedVector(size_t capacity=G4RWDEFAULT_CAPACITY);
|
||||
G4RWTValOrderedVector(const G4RWTValOrderedVector<T>&);
|
||||
virtual ~G4RWTValOrderedVector();
|
||||
|
||||
inline G4RWTValOrderedVector<T>& operator=(const G4RWTValOrderedVector<T>&);
|
||||
|
||||
inline T& operator()(size_t);
|
||||
inline const T& operator()(size_t) const;
|
||||
inline T& operator[](size_t);
|
||||
inline const T& operator[](size_t) const;
|
||||
|
||||
inline T& at (size_t);
|
||||
inline T at (size_t) const;
|
||||
|
||||
void resize (size_t);
|
||||
void clear( void );
|
||||
G4bool contains(const T) const;
|
||||
inline size_t length() const;
|
||||
size_t index (const T&);
|
||||
|
||||
inline G4bool insert (const T&);
|
||||
void insertAt (size_t, const T&);
|
||||
|
||||
size_t occurrencesOf (const T&) const;
|
||||
|
||||
G4bool remove (const T&);
|
||||
size_t removeAll (const T&);
|
||||
T removeAt (size_t);
|
||||
|
||||
size_t entries () const;
|
||||
inline void append (const T&);
|
||||
|
||||
inline T first() const;
|
||||
inline T last() const;
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
};
|
||||
|
||||
// Include actual implementations of templated class methods.
|
||||
|
||||
#include "g4rw/tvordvec.icc"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
// 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: tvordvec.icc,v 1.1 1999/11/25 10:14:46 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTValOrderedVector
|
||||
//---------------------------------------------------------------
|
||||
|
||||
template<class T>
|
||||
G4RWTValOrderedVector<T>::G4RWTValOrderedVector(size_t capacity)
|
||||
: std_vector(capacity),rwsize(0){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValOrderedVector<T>::G4RWTValOrderedVector(const G4RWTValOrderedVector<T>& v)
|
||||
: std_vector(v),rwsize(v.rwsize){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValOrderedVector<T>::~G4RWTValOrderedVector(){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValOrderedVector<T>&
|
||||
G4RWTValOrderedVector<T>::operator=(const G4RWTValOrderedVector<T>& v)
|
||||
{
|
||||
std_vector::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& G4RWTValOrderedVector<T>::operator()(size_t i)
|
||||
{
|
||||
//if(i>=rwsize)
|
||||
// G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector ()",rwsize,i));
|
||||
if(i<std_vector::size() && rwsize<=i)
|
||||
rwsize=i+1;
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& G4RWTValOrderedVector<T>::operator()(size_t i) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector const()",rwsize,i));
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& G4RWTValOrderedVector<T>::operator[](size_t i)
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector []",rwsize,i));
|
||||
//if(i<std_vector::size() && rwsize<=i)
|
||||
// rwsize=i+1;
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& G4RWTValOrderedVector<T>::operator[](size_t i) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector const []",rwsize,i));
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& G4RWTValOrderedVector<T>::at(size_t n)
|
||||
{
|
||||
if(n>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector at",rwsize,n));
|
||||
return operator()(n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T G4RWTValOrderedVector<T>::at(size_t n ) const
|
||||
{
|
||||
if(n>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector const at",rwsize,n));
|
||||
return operator()(n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTValOrderedVector<T>::clear( void )
|
||||
{
|
||||
//std_vector::erase(std_vector::begin(), std_vector::end());
|
||||
for(size_t i=0;i<rwsize;i++)
|
||||
std_vector::operator[](i)=T();
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValOrderedVector<T>::length() const
|
||||
{
|
||||
return rwsize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValOrderedVector<T>::entries () const
|
||||
{
|
||||
return rwsize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTValOrderedVector<T>::append ( const T& a )
|
||||
{
|
||||
insert ( a );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T G4RWTValOrderedVector<T>::first() const
|
||||
{
|
||||
if(!rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector first",rwsize,0));
|
||||
return std_vector::front();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T G4RWTValOrderedVector<T>::last() const
|
||||
{
|
||||
if(rwsize)
|
||||
return std_vector::operator[](rwsize-1);
|
||||
else
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector last",rwsize,0));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValOrderedVector<T>::index( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
for (i = std_vector::begin();ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (*i==a) return ptn;
|
||||
}
|
||||
return (ptn=~(size_t)0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValOrderedVector<T>::occurrencesOf( const T& a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
for (i = std_vector::begin(); sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (*i==a) ptn++;
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTValOrderedVector<T>::remove( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = std_vector::begin(); sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (*i==a)
|
||||
{
|
||||
std_vector::erase(i);
|
||||
rwsize--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValOrderedVector<T>::removeAll( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = std_vector::begin();sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (*i==a)
|
||||
{
|
||||
std_vector::erase(i);
|
||||
ptn++;
|
||||
i--;
|
||||
rwsize--;
|
||||
}
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T G4RWTValOrderedVector<T>::removeAt( size_t i )
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector removeAt",rwsize,i));
|
||||
T tmp = operator[](i);
|
||||
iterator it=std_vector::begin();
|
||||
int j;
|
||||
for(j=0;j<rwsize && j<i;j++) it++;
|
||||
if(it!=std_vector::end())
|
||||
{
|
||||
std_vector::erase(it);
|
||||
rwsize--;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTValOrderedVector<T>::resize(size_t N)
|
||||
{
|
||||
if(N>std_vector::size())
|
||||
{
|
||||
int e=N-std_vector::size();
|
||||
for(int i=0;i<e;i++)
|
||||
std_vector::push_back(T());
|
||||
}
|
||||
else if(N>rwsize )
|
||||
{
|
||||
iterator it=std_vector::begin();
|
||||
for(int i=0;i<N;i++,it++);
|
||||
std_vector::erase(it,std_vector::end());
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTValOrderedVector<T>::contains( const T a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t sz=0;
|
||||
for (i = std_vector::begin();sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (*i==a) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
G4bool G4RWTValOrderedVector<T>::insert ( const T& a )
|
||||
{
|
||||
if(rwsize<std_vector::size())
|
||||
{
|
||||
this->std_vector::operator[](rwsize)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
std_vector::push_back(a);
|
||||
rwsize=std_vector::size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// insertAt throws an exception of type G4RWBoundsErr if you try
|
||||
// to insert out of range
|
||||
//
|
||||
template<class T>
|
||||
void G4RWTValOrderedVector<T>::insertAt ( size_t i, const T& a )
|
||||
{
|
||||
if(i>rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValOrderedVector insertAt",rwsize,i));
|
||||
if(rwsize<std_vector::size())
|
||||
{
|
||||
for(int j=rwsize;j>i;j--)
|
||||
std_vector::operator[](j)=this->std_vector::operator[](j-1);
|
||||
std_vector::operator[](i)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=std_vector::begin();
|
||||
for(int j=0;j<i;j++,it++);
|
||||
std_vector::insert(it,a);
|
||||
rwsize++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// 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: tvvector.h,v 1.7 1999/11/26 17:17:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTValVector
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// STL wrapper class for Value arrays. It implements
|
||||
// Rogue Wave RWTValVector signature but intrinsically
|
||||
// using STL vector.
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef __tvvector
|
||||
#define __tvvector
|
||||
|
||||
#include "g4std/vector"
|
||||
#include "g4rw/defs.h"
|
||||
|
||||
template<class T>
|
||||
class G4RWTValVector : public G4std::vector<T>
|
||||
{
|
||||
|
||||
typedef G4std::vector<T> std_vector;
|
||||
typedef typename std_vector::iterator iterator;
|
||||
typedef typename std_vector::const_iterator const_iterator;
|
||||
|
||||
public:
|
||||
|
||||
G4RWTValVector ();
|
||||
G4RWTValVector (size_t);
|
||||
G4RWTValVector (size_t, const T&);
|
||||
G4RWTValVector (const G4RWTValVector<T>&);
|
||||
virtual ~G4RWTValVector();
|
||||
|
||||
inline G4RWTValVector<T>& operator= (const G4RWTValVector<T>&);
|
||||
|
||||
inline T& operator()(size_t);
|
||||
inline const T& operator()(size_t) const;
|
||||
inline T& operator[](size_t);
|
||||
inline const T& operator[](size_t) const;
|
||||
|
||||
inline size_t length() const;
|
||||
|
||||
inline const T* data() const;
|
||||
void resize(size_t);
|
||||
inline void reshape(size_t);
|
||||
inline const T& ref(size_t) const;
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
};
|
||||
|
||||
// Include actual implementations of templated class methods.
|
||||
|
||||
#include "g4rw/tvvector.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
// 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: tvvector.icc,v 1.1 1999/11/25 10:14:47 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4RWTValVector
|
||||
//---------------------------------------------------------------
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>::G4RWTValVector ()
|
||||
: rwsize(0){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>::G4RWTValVector (size_t n)
|
||||
: std_vector(n), rwsize(n){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>::G4RWTValVector (size_t n, const T& ival)
|
||||
: std_vector(n,ival), rwsize(n){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>::G4RWTValVector (const G4RWTValVector<T>& ival)
|
||||
: std_vector(ival), rwsize(ival.rwsize){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>::~G4RWTValVector(){}
|
||||
|
||||
template<class T>
|
||||
G4RWTValVector<T>&
|
||||
G4RWTValVector<T>::operator= (const G4RWTValVector<T>& v)
|
||||
{
|
||||
std_vector::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t G4RWTValVector<T>::length() const
|
||||
{
|
||||
return std_vector::size();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& G4RWTValVector<T>::operator()(size_t i)
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValVector operator()",rwsize,i));
|
||||
if(i<std_vector::size() && rwsize<i)
|
||||
rwsize=i+1;
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& G4RWTValVector<T>::operator()(size_t i) const
|
||||
{
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& G4RWTValVector<T>::operator[](size_t i)
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValVector operator[]",rwsize,i));
|
||||
if(i<std_vector::size() && rwsize<i)
|
||||
rwsize=i+1;
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& G4RWTValVector<T>::operator[](size_t i) const
|
||||
{
|
||||
if(i>=rwsize)
|
||||
G4RWTHROW(G4RWBoundsErr("G4RWTValVector const operator[]",rwsize,i));
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T* G4RWTValVector<T>::data() const
|
||||
{
|
||||
return &(std_vector::front());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTValVector<T>::resize(size_t N)
|
||||
{
|
||||
if(N>std_vector::size())
|
||||
{
|
||||
int e=N-std_vector::size();
|
||||
for(int i=0;i<e;i++)
|
||||
std_vector::push_back(T());
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=std_vector::begin();
|
||||
for(int i=1;i<=N;i++,it++);
|
||||
std_vector::erase(it,std_vector::end());
|
||||
}
|
||||
rwsize=N;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void G4RWTValVector<T>::reshape(size_t n)
|
||||
{
|
||||
resize(n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const T& G4RWTValVector<T>::ref(size_t i) const
|
||||
{
|
||||
return std_vector::operator[](i);
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
#ifndef __cstring
|
||||
#define __cstring
|
||||
|
||||
#include <string>
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::string;
|
||||
#endif
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <cstring>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "rw/defs.h"
|
||||
|
||||
#if defined(__KCC)
|
||||
#include <istream>
|
||||
#define std_string std::string
|
||||
#define std_istream std::istream
|
||||
#define std_ws std::ws
|
||||
#else
|
||||
#define std_string string
|
||||
#define std_istream istream
|
||||
#define std_ws ws
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
class RWCString;
|
||||
|
||||
class RWCSubString
|
||||
{
|
||||
public:
|
||||
|
||||
inline RWCSubString(const RWCSubString&);
|
||||
|
||||
inline RWCSubString& operator=(const char*);
|
||||
|
||||
inline RWCSubString& operator=(const RWCString&s);
|
||||
inline RWCSubString& operator=(const RWCSubString&s);
|
||||
|
||||
inline char& operator()(size_t i);
|
||||
inline char operator()(size_t i) const;
|
||||
inline char& operator[](size_t i);
|
||||
inline char operator[](size_t i) const;
|
||||
size_t length() const{return extent;}
|
||||
size_t start() const{return mystart;}
|
||||
//void toLower();
|
||||
//void toUpper();
|
||||
|
||||
// For detecting null substrings:
|
||||
RWBoolean isNull() const
|
||||
{return extent==0 ? true : false;}
|
||||
|
||||
int operator!() const
|
||||
{return extent==0 ? 1 : 0;}
|
||||
|
||||
inline RWBoolean operator==(RWCString) const;
|
||||
inline RWBoolean operator==(const char*) const;
|
||||
|
||||
inline RWBoolean operator!=(RWCString) const;
|
||||
inline RWBoolean operator!=(const char*) const;
|
||||
|
||||
private:
|
||||
|
||||
RWCSubString(RWCString&str,size_t s,size_t e):
|
||||
mystring(&str),mystart(s),extent(e){}
|
||||
|
||||
RWCString* mystring;
|
||||
size_t mystart;
|
||||
size_t extent;
|
||||
|
||||
friend class RWCString;
|
||||
|
||||
};
|
||||
|
||||
//#define std
|
||||
|
||||
class RWCString : public std_string {
|
||||
|
||||
public:
|
||||
|
||||
enum caseCompare { exact, ignoreCase };
|
||||
enum stripType { leading, trailing, both };
|
||||
|
||||
inline RWCString ( const char * );
|
||||
|
||||
RWCString ( char c )
|
||||
{
|
||||
char str[2];
|
||||
str[0]=c;
|
||||
str[1]='\0';
|
||||
std_string::operator=(str);
|
||||
}
|
||||
|
||||
RWCString (){}
|
||||
RWCString ( const RWCString& s):std_string(s){}
|
||||
RWCString( const RWCSubString&s ):std_string(*(s.mystring),s.mystart,s.extent){}
|
||||
RWCString ( const std_string s ):std_string(s){}
|
||||
|
||||
RWCString& operator=(const RWCString&s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
RWCString& operator=(const std_string&s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
RWCString& operator=(const char* s)
|
||||
{
|
||||
std_string::operator=(s);
|
||||
return *this;
|
||||
}
|
||||
virtual ~RWCString (){}
|
||||
inline char operator () (size_t) const;
|
||||
char& operator () (size_t i){return std_string::operator[](i);}
|
||||
int compareTo(const char*s,caseCompare mode=exact)
|
||||
{
|
||||
//GB:OSF1-cxx if(mode=exact)
|
||||
if(mode==exact)
|
||||
return strcmp(c_str(),s);
|
||||
else
|
||||
return strcasecmp(c_str(),s);
|
||||
}
|
||||
int compareTo(const RWCString&s,caseCompare mode=exact)
|
||||
{
|
||||
//GB:OSF1-cxx if(mode=exact)
|
||||
if(mode==exact)
|
||||
return strcmp(data(),s.data());
|
||||
else
|
||||
return strcasecmp(data(),s.data());
|
||||
}
|
||||
RWCString& operator+=(const RWCSubString&s)
|
||||
{
|
||||
RWCString tmp(s);
|
||||
std_string::operator+=(tmp);
|
||||
return *this;
|
||||
}
|
||||
RWCString& operator+=(const char*s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
RWCString& operator+=(const std_string &s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
RWCString& operator+=(const char &c)
|
||||
{
|
||||
std_string::operator+=(c);
|
||||
return *this;
|
||||
}
|
||||
RWBoolean operator==(const RWCString &s) const
|
||||
{
|
||||
const string *a=this;
|
||||
const string *b=&s;
|
||||
return *a==*b;
|
||||
}
|
||||
RWBoolean operator==(const char* s) const
|
||||
{
|
||||
const string *a=this;
|
||||
const string b=s;
|
||||
return *a==b;
|
||||
}
|
||||
RWBoolean operator!=(const RWCString &s) const
|
||||
{
|
||||
const string *a=this;
|
||||
const string *b=&s;
|
||||
return *a!=*b;
|
||||
}
|
||||
RWBoolean operator!=(const char* s) const
|
||||
{
|
||||
const string *a=this;
|
||||
const string b=s;
|
||||
return *a!=b;
|
||||
}
|
||||
|
||||
//inline RWCString operator () (unsigned int, unsigned int);
|
||||
inline operator const char*() const {return c_str();};
|
||||
RWCString& prepend (const char*str)
|
||||
{
|
||||
insert(0,str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RWCString& append(const RWCString&s)
|
||||
{
|
||||
std_string::operator+=(s);
|
||||
return *this;
|
||||
}
|
||||
inline std_istream& readLine ( std_istream&, RWBoolean skipWhite=true);
|
||||
inline RWCString& replace (unsigned int, unsigned int,
|
||||
const char*, unsigned int );
|
||||
RWCString& replace(size_t pos,size_t n,const char*s)
|
||||
{
|
||||
std_string::replace(pos,n,s);
|
||||
return *this;
|
||||
}
|
||||
RWCString& remove(size_t n)
|
||||
{
|
||||
if(n<size())
|
||||
erase(n,size()-n);
|
||||
return *this;
|
||||
}
|
||||
RWCString& remove(size_t pos,size_t N)
|
||||
{
|
||||
erase(pos,N+pos);
|
||||
return *this;
|
||||
}
|
||||
int first(char c) const{return find(c);}
|
||||
int last(char c) const{return rfind(c);}
|
||||
|
||||
RWBoolean contains(std_string s) const
|
||||
{
|
||||
int i=find(s);
|
||||
if(i!=std_string::npos) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
RWBoolean contains(char c) const
|
||||
{
|
||||
int i=find(c);
|
||||
if(i!=std_string::npos) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// stripType = 0 beginning
|
||||
// stripType = 1 end
|
||||
// stripType = 2 both
|
||||
//
|
||||
inline RWCString strip ( int stripType, char );
|
||||
inline void toLower ( void );
|
||||
inline void toUpper ( void );
|
||||
inline RWBoolean isNull() const {return empty ();}
|
||||
inline size_t index (const char*,int pos=0) const;
|
||||
inline size_t index (char,int pos=0) const;
|
||||
inline size_t index( const RWCString&, size_t, size_t, caseCompare ) const;
|
||||
RWCSubString operator()(size_t start, size_t extent)
|
||||
{
|
||||
return RWCSubString(*this,start,extent);
|
||||
}
|
||||
|
||||
const char* data() const{return c_str();}
|
||||
|
||||
unsigned int hash( caseCompare cmp = exact ) const
|
||||
{
|
||||
const char*s=c_str();
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
|
||||
unsigned int stlhash() const
|
||||
{
|
||||
const char*s=c_str();
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
|
||||
// useful for supplying hash functions to template hash collection ctors:
|
||||
static unsigned hash(const RWCString&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
RWCSubString::RWCSubString(const RWCSubString&s)
|
||||
{
|
||||
mystring=s.mystring;
|
||||
mystart=s.mystart;
|
||||
extent=s.extent;
|
||||
}
|
||||
|
||||
RWCSubString& RWCSubString::operator=(const RWCString&s)
|
||||
{
|
||||
RWCString str(s);
|
||||
return operator=(str);
|
||||
}
|
||||
RWCSubString& RWCSubString::operator=(const RWCSubString&s)
|
||||
{
|
||||
mystring->replace(mystart,extent,s.mystring->data(),s.length());
|
||||
extent=s.length();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RWCSubString& RWCSubString::operator=(const char*s)
|
||||
{
|
||||
mystring->replace(mystart,extent,s,strlen(s));
|
||||
extent=strlen(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
char& RWCSubString::operator()(size_t i)
|
||||
{return mystring->operator[](mystart+i);}
|
||||
|
||||
char RWCSubString::operator()(size_t i) const
|
||||
{return mystring->operator[](mystart+i);}
|
||||
|
||||
char& RWCSubString::operator[](size_t i)
|
||||
{return mystring->operator[](mystart+i);}
|
||||
|
||||
char RWCSubString::operator[](size_t i) const
|
||||
{return mystring->operator[](mystart+i);}
|
||||
|
||||
RWBoolean RWCSubString::operator==(RWCString s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent)==s ? true:false;
|
||||
}
|
||||
|
||||
RWBoolean RWCSubString::operator==(const char* s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent)==string(s) ? true:false;
|
||||
}
|
||||
|
||||
RWBoolean RWCSubString::operator!=(RWCString s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent)!=string(s) ? true:false;
|
||||
}
|
||||
|
||||
RWBoolean RWCSubString::operator!=(const char* s) const
|
||||
{
|
||||
return mystring->substr(mystart,extent)!=string(s) ? true:false;
|
||||
}
|
||||
|
||||
//#include <rw/cstring.icc>
|
||||
|
||||
//GB:OSF1-cxx : #include <cstring>
|
||||
|
||||
RWCString::RWCString ( const char * astring ) : std_string ( astring ) {}
|
||||
|
||||
void RWCString::toLower ( void ) {
|
||||
for (int i=0; i<=size();i++) {
|
||||
//GB:HP-UX-aCC,Linux-KCC (*this)[i] = tolower((*this)[i]);
|
||||
at(i) = tolower(at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void RWCString::toUpper ( void ) {
|
||||
for (int i=0; i<=size();i++) {
|
||||
//GB:HP-UX-aCC,Linux-KCC (*this)[i] = toupper((*this)[i]);
|
||||
at(i) = toupper(at(i));
|
||||
}
|
||||
}
|
||||
|
||||
std_istream& RWCString::readLine ( std_istream& s, RWBoolean skipWhite/*GB:OSF1-cxx =true*/ ) {
|
||||
char tmp[256];
|
||||
if ( skipWhite ) {
|
||||
s >> std_ws;
|
||||
s.getline(tmp,256);
|
||||
*this=tmp;
|
||||
}
|
||||
else {
|
||||
s.getline(tmp,256);
|
||||
*this=tmp;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
RWCString& RWCString::replace (unsigned int start, unsigned int nbytes,
|
||||
const char* buff, unsigned int n2 ) {
|
||||
std_string::replace ( start, nbytes, buff, n2 );
|
||||
return *this;
|
||||
}
|
||||
|
||||
RWCString RWCString::strip ( int stripType=trailing, char c=' ' ) {
|
||||
RWCString retVal = *this;
|
||||
if(length()==0) return retVal;
|
||||
int i;
|
||||
switch ( stripType ) {
|
||||
case leading:
|
||||
{
|
||||
for(i=0;i<length();i++)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
retVal = substr(i,length()-i);
|
||||
}
|
||||
break;
|
||||
case trailing:
|
||||
{
|
||||
for(i=length()-1;i>=0;i--)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
retVal = substr(0,i+1);
|
||||
}
|
||||
break;
|
||||
case both:
|
||||
{
|
||||
for(i=0;i<length();i++)
|
||||
if (std_string::operator[](i) != c) break;
|
||||
RWCString tmp(substr(i,length()-i));
|
||||
for(i=tmp.length()-1;i>=0;i--)
|
||||
if (tmp.std_string::operator[](i) != c) break;
|
||||
retVal = tmp.substr(0,i+1);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// "cs" optional parameter is NOT implemented !
|
||||
size_t RWCString::index( const RWCString& s, size_t ln,
|
||||
size_t st, RWCString::caseCompare cs ) const {
|
||||
return std_string::find( s.c_str(), st, ln );
|
||||
}
|
||||
|
||||
// "cmp" optional parameter is NOT implemented !
|
||||
// N.B.: The hash value returned is generally DIFFERENT from the
|
||||
// one returned by the original RW function.
|
||||
// Users should not rely on the specific return value.
|
||||
|
||||
char RWCString::operator () (size_t i) const
|
||||
{
|
||||
return operator[](i);
|
||||
}
|
||||
|
||||
size_t RWCString::index (const char* str,int pos) const
|
||||
{
|
||||
return std_string::find(str,pos);
|
||||
}
|
||||
|
||||
size_t RWCString::index (char c,int pos) const
|
||||
{
|
||||
return std_string::find(c,pos);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#ifndef __ctoken
|
||||
#define __ctoken
|
||||
|
||||
#include <string>
|
||||
#include "rw/defs.h"
|
||||
#include "rw/cstring.h"
|
||||
|
||||
class RWCTokenizer
|
||||
{
|
||||
public:
|
||||
RWCTokenizer(const RWCString& s):string2tokenize(s),actual(0){}
|
||||
|
||||
RWCSubString operator()(const char* str=" \t\n",size_t l=0)
|
||||
{
|
||||
size_t i,j,tmp;
|
||||
RWBoolean hasws=false;
|
||||
if(l==0) l=strlen(str);
|
||||
//Skip leading delimeters
|
||||
while(actual<string2tokenize.size())
|
||||
{
|
||||
|
||||
for(i=0;i<l;i++)
|
||||
if(string2tokenize[actual]==str[i]) hasws=true;
|
||||
if(hasws)
|
||||
{
|
||||
actual++;
|
||||
hasws=false;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for(j=actual;j<string2tokenize.size();j++)
|
||||
{
|
||||
for(i=0;i<l;i++)
|
||||
if(string2tokenize[j]==str[i]) break;
|
||||
if(i<l) break;
|
||||
}
|
||||
if(j!=string2tokenize.size())
|
||||
{
|
||||
tmp=actual;
|
||||
actual=j+1;
|
||||
return string2tokenize(tmp,j-tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp=actual;
|
||||
actual=j;
|
||||
return string2tokenize(tmp,j-tmp);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
RWCString string2tokenize;
|
||||
size_t actual;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
#ifndef __defs
|
||||
#define __defs
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
# include <cstdio>
|
||||
# include <cstring>
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#define RWDEFAULT_CAPACITY (64)
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
const size_t RW_NPOS = ~(size_t)0;
|
||||
#define CLHEP_MAX_MIN_DEFINED
|
||||
#include <CLHEP/config/TemplateFunctions.h>
|
||||
|
||||
#ifdef G4_HAVE_BOOL
|
||||
typedef bool RWBoolean;
|
||||
#else
|
||||
typedef HepBoolean RWBoolean;
|
||||
#endif
|
||||
|
||||
class RWBoundsErr
|
||||
{
|
||||
public:
|
||||
|
||||
RWBoundsErr(const char* s,int b=0,int v=0)
|
||||
{
|
||||
char btmp[80],vtmp[80];
|
||||
sprintf(btmp,"%d",b);
|
||||
sprintf(vtmp,"%d",v);
|
||||
str=new char[strlen(s)+8+strlen(btmp)+7+strlen(vtmp)+1];
|
||||
strcpy(str,s);
|
||||
strcat(str,": bound:");
|
||||
strcat(str,btmp);
|
||||
strcat(str," value:");
|
||||
strcat(str,vtmp);
|
||||
}
|
||||
|
||||
RWBoundsErr(const RWBoundsErr&e)
|
||||
{
|
||||
str=new char[strlen(e.str)+1];
|
||||
strcpy(str,e.str);
|
||||
}
|
||||
|
||||
~RWBoundsErr()
|
||||
{
|
||||
delete str;
|
||||
}
|
||||
|
||||
const char * why() const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
char* str;
|
||||
|
||||
};
|
||||
|
||||
class RWGeneralException
|
||||
{
|
||||
public:
|
||||
|
||||
RWGeneralException(const char* s)
|
||||
{
|
||||
str=new char[strlen(s)+1];
|
||||
strcpy(str,s);
|
||||
}
|
||||
|
||||
RWGeneralException(const RWGeneralException&e)
|
||||
{
|
||||
str=new char[strlen(e.str)+1];
|
||||
strcpy(str,e.str);
|
||||
}
|
||||
|
||||
~RWGeneralException()
|
||||
{
|
||||
delete str;
|
||||
}
|
||||
|
||||
const char * why() const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
char* str;
|
||||
|
||||
};
|
||||
|
||||
#define RWTHROW(a) throw a
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef __rstream
|
||||
#define __rstream
|
||||
|
||||
#include "rw/defs.h"
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <iostream>
|
||||
#else
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
inline istream& rwEatwhite(istream& stream) {return stream >> ws;}
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef rw2stl_algo_h
|
||||
#define rw2stl_algo_h
|
||||
|
||||
#include "rw/defs.h"
|
||||
|
||||
template <class T>
|
||||
class RW2STL_LessPtr
|
||||
{
|
||||
public:
|
||||
|
||||
RWBoolean operator()(const T* a, const T* b) const
|
||||
{
|
||||
if(a==0) return false;
|
||||
if(b==0) return true;
|
||||
return *a<*b;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef rwstlhash_h
|
||||
#define rwstlhash_h
|
||||
|
||||
class G4ParticleDefinition;
|
||||
class _WidgetRec;
|
||||
|
||||
inline unsigned HashDefault( const G4ParticleDefinition* const & p)
|
||||
{
|
||||
return (unsigned) p;
|
||||
}
|
||||
|
||||
inline unsigned HashDefault( _WidgetRec* const & p)
|
||||
{
|
||||
return (unsigned) p;
|
||||
}
|
||||
|
||||
inline unsigned HashDefault( const int& p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template < class K >
|
||||
unsigned HashDefault( const K& p)
|
||||
{
|
||||
return p.stlhash();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,296 +0,0 @@
|
||||
#ifndef __tphdict
|
||||
#define __tphdict
|
||||
|
||||
#include "rw/defs.h"
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <vector>
|
||||
#else
|
||||
#include <vector.h>
|
||||
#endif
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <hash_map>
|
||||
#include <set>
|
||||
#include <functional>
|
||||
#else
|
||||
# include <set.h>
|
||||
# include <function.h>
|
||||
# if defined(WIN32) && defined(OS_WIN_NT_4_0)
|
||||
// OBJECT Space on WIN32 choose to change this name..
|
||||
# include <hashmap.h>
|
||||
# else
|
||||
# include <hash_map.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class PK>
|
||||
class Equal_Ptr_To
|
||||
{
|
||||
public:
|
||||
Equal_Ptr_To(){}
|
||||
RWBoolean operator()(const PK*a,const PK*b) const
|
||||
{return *a==*b;}
|
||||
};
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::set;
|
||||
#endif
|
||||
|
||||
#include "rw/rwstlhash.h"
|
||||
|
||||
|
||||
template < class PK >
|
||||
class HashPtr {
|
||||
public:
|
||||
HashPtr(unsigned (*f)( const PK &)=HashDefault):fhashfun(f){}
|
||||
HashPtr(const HashPtr<PK>&s):fhashfun(s.fhashfun){}
|
||||
unsigned operator()( PK* key ) const;
|
||||
void SetHashFun( unsigned (*hashfun)( const PK& ) );
|
||||
private:
|
||||
unsigned (*fhashfun)( const PK & );
|
||||
};
|
||||
|
||||
#define hash_dict_t hash_map< K*, V*, HashPtr<K>,Equal_Ptr_To<K> >
|
||||
|
||||
template < class K, class V >
|
||||
class RWTPtrHashDictionary
|
||||
{
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef os_hash_table_iterator
|
||||
<
|
||||
OS_PAIR( K*, V* ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K*, V* ) )
|
||||
> iterator;
|
||||
typedef os_hash_table_const_iterator
|
||||
<
|
||||
OS_PAIR( K*, V* ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K*, V* ) )
|
||||
> const_iterator;
|
||||
#else
|
||||
typedef hash_dict_t::iterator iterator;
|
||||
typedef hash_dict_t::const_iterator const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
RWTPtrHashDictionary( unsigned (*hashfun)( const K& key ),size_t n=100)
|
||||
:fhm(n,HashPtr<K>(hashfun),Equal_Ptr_To<K>()){}
|
||||
|
||||
// Default copy constructor ?
|
||||
RWTPtrHashDictionary( const RWTPtrHashDictionary<K,V>& aPtrHashDict ):
|
||||
fhm( aPtrHashDict.fhm ){}
|
||||
|
||||
V*& operator[]( K*& key ) {return fhm[key]; }
|
||||
void clear() { fhm.clear(); }
|
||||
void clearAndDestroy( void )
|
||||
{
|
||||
//We are deleting in reverse order
|
||||
set<K*,greater<K*> > ktmp;
|
||||
set<V*,greater<V*> > vtmp;
|
||||
for(iterator it=fhm.begin();
|
||||
it!=fhm.end();it++)
|
||||
{
|
||||
K* kcurrent;
|
||||
V* vcurrent;
|
||||
kcurrent=((*it).first);
|
||||
vcurrent=((*it).second);
|
||||
if ( kcurrent )
|
||||
ktmp.insert(kcurrent);
|
||||
if ( vcurrent )
|
||||
vtmp.insert(vcurrent);
|
||||
}
|
||||
typename set<K*,greater<K*> >::iterator kit;
|
||||
for(kit=ktmp.begin();kit!=ktmp.end();kit++)
|
||||
{
|
||||
delete *kit;
|
||||
}
|
||||
typename set<V*,greater<V*> >::iterator vit;
|
||||
for(vit=vtmp.begin();vit!=vtmp.end();vit++)
|
||||
{
|
||||
delete *vit;
|
||||
}
|
||||
fhm.clear();
|
||||
}
|
||||
|
||||
void clearAndDestroyKey(void)
|
||||
{
|
||||
//We are deleting in reverse order
|
||||
set<K*,greater<K*> > ktmp;
|
||||
for(iterator it=fhm.begin();
|
||||
it!=fhm.end();it++)
|
||||
{
|
||||
K* kcurrent;
|
||||
kcurrent=((*it).first);
|
||||
if ( kcurrent )
|
||||
ktmp.insert(kcurrent);
|
||||
}
|
||||
typename set<K*,greater<K*> >::iterator kit;
|
||||
for(kit=ktmp.begin();kit!=ktmp.end();kit++)
|
||||
{
|
||||
delete *kit;
|
||||
}
|
||||
fhm.clear();
|
||||
}
|
||||
|
||||
K* find ( const K* key )
|
||||
{
|
||||
iterator it;
|
||||
// The STL RW const problem
|
||||
K tval(*key);
|
||||
K* tptr=&tval;
|
||||
it=fhm.find(tptr);
|
||||
if(it!=fhm.end())
|
||||
return (*it).first;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
V* findValue( const K* key )
|
||||
{
|
||||
iterator it;
|
||||
// The STL RW const problem
|
||||
K tval(*key);
|
||||
K* tptr=&tval;
|
||||
it=fhm.find(tptr);
|
||||
if(it!=fhm.end())
|
||||
return (*it).second;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void insertKeyAndValue (K* key, V* value) {fhm[key]=value;}
|
||||
K* remove(const K* key) {
|
||||
iterator i;
|
||||
K tmp(*key);
|
||||
K* ptr=&tmp;
|
||||
i = fhm.find(ptr);
|
||||
if ( i == fhm.end() ) { return NULL; }
|
||||
else {
|
||||
ptr=(*i).first;
|
||||
fhm.erase( i );
|
||||
return ptr;
|
||||
}
|
||||
};
|
||||
void resize( unsigned N ) { fhm.resize(N); }
|
||||
K* findKeyAndValue( const K* key, V*& retval )
|
||||
{
|
||||
iterator i;
|
||||
K tmp(*key);
|
||||
K* ptr=&tmp;
|
||||
i = fhm.find(ptr );
|
||||
if ( i == fhm.end() ) { return false; }
|
||||
else {
|
||||
retval = (*i).second;
|
||||
return (*i).first;
|
||||
}
|
||||
}
|
||||
|
||||
size_t entries() const {return fhm.size();}
|
||||
size_t max_size() const {return fhm.max_size();}
|
||||
size_t bucket_count() const {return fhm.bucket_count();}
|
||||
|
||||
RWBoolean contains(const K* Key) const
|
||||
{
|
||||
const_iterator it;
|
||||
// The STL RW const problem
|
||||
K tval(*Key);
|
||||
K* tptr=&tval;
|
||||
it=fhm.find(tptr);
|
||||
if(it!=fhm.end())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//This is STL, so will not be used by RW
|
||||
iterator begin(){return fhm.begin();}
|
||||
iterator end(){return fhm.end();}
|
||||
|
||||
private:
|
||||
|
||||
hash_dict_t fhm;
|
||||
};
|
||||
|
||||
template < class K, class V >
|
||||
class RWTPtrHashDictionaryIterator {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef os_hash_table_iterator
|
||||
<
|
||||
OS_PAIR( K*, V* ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K*, V* ) )
|
||||
> iterator;
|
||||
typedef os_hash_table_const_iterator
|
||||
<
|
||||
OS_PAIR( K*, V* ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K*, V* ) )
|
||||
> const_iterator;
|
||||
#else
|
||||
typedef hash_dict_t::iterator iterator;
|
||||
typedef hash_dict_t::const_iterator const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTPtrHashDictionaryIterator(RWTPtrHashDictionary<K,V>&adict):
|
||||
mydict(&adict),it(adict.begin()),defined(false){}
|
||||
|
||||
RWBoolean operator++ ()
|
||||
{
|
||||
if(!defined) return false;
|
||||
it++;
|
||||
return it!=mydict->end() ? true : false;
|
||||
}
|
||||
|
||||
RWBoolean operator()()
|
||||
{
|
||||
if(defined)
|
||||
return operator++();
|
||||
else
|
||||
{
|
||||
defined=true;
|
||||
it=mydict->begin();
|
||||
return it!=mydict->end() ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
K* key () const {return (*it).first;}
|
||||
|
||||
void reset (){defined=false;}
|
||||
V* value () const{return (*it).second;}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
iterator it;
|
||||
RWTPtrHashDictionary<K,V>* mydict;
|
||||
RWBoolean defined;
|
||||
};
|
||||
|
||||
template< class PK >
|
||||
unsigned HashPtr<PK>::operator()( PK * key ) const {
|
||||
return fhashfun( *key );
|
||||
}
|
||||
|
||||
template< class PK >
|
||||
void HashPtr<PK>::SetHashFun( unsigned (*hashfun)( const PK& ) ) {
|
||||
fhashfun = hashfun;
|
||||
}
|
||||
|
||||
#undef hash_dict_t
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,378 +0,0 @@
|
||||
#ifndef __tpordvec
|
||||
#define __tpordvec
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
# include <vector>
|
||||
# include <set>
|
||||
# include <functional>
|
||||
#else
|
||||
# include <vector.h>
|
||||
# include <set.h>
|
||||
# include <function.h>
|
||||
#endif
|
||||
#include "rw/defs.h"
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::vector;
|
||||
using std::set;
|
||||
#endif
|
||||
|
||||
|
||||
template<class T> class RWTPtrOrderedVector : public vector<T*> {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef T** iterator;
|
||||
typedef T* const* const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTPtrOrderedVector(size_t capacity=RWDEFAULT_CAPACITY):
|
||||
vector<T*>(capacity,(T*)0),rwsize(0){}
|
||||
|
||||
RWTPtrOrderedVector(const RWTPtrOrderedVector<T>& v):
|
||||
vector<T*>(v),rwsize(v.rwsize){}
|
||||
|
||||
RWTPtrOrderedVector<T>& operator=(const RWTPtrOrderedVector<T>& v)
|
||||
{
|
||||
vector<T*>::operator=(v),
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~RWTPtrOrderedVector(){}
|
||||
|
||||
T*& operator()(size_t i)
|
||||
{
|
||||
//if(i<0 || i>=rwsize)
|
||||
// RWTHROW(RWBoundsErr("RWTPtrOrderedVector ()",rwsize,i));
|
||||
if(i<vector<T*>::size() && rwsize<=i) rwsize=i+1;
|
||||
return vector<T*>::operator[](i);
|
||||
}
|
||||
|
||||
T* const& operator()(size_t i) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector const ()",rwsize,i));
|
||||
return vector<T*>::operator[](i);
|
||||
}
|
||||
|
||||
T*& operator[](size_t i)
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector []",rwsize,i));
|
||||
//if(i<vector<T*>::size() && rwsize<=i) rwsize=i+1;
|
||||
return vector<T*>::operator[](i);
|
||||
}
|
||||
|
||||
T* const& operator[](size_t i) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector const []",rwsize,i));
|
||||
return vector<T*>::operator[](i);
|
||||
}
|
||||
|
||||
|
||||
void clearAndDestroy();
|
||||
|
||||
void clear();
|
||||
|
||||
size_t index ( const T*) const;
|
||||
|
||||
void resize(size_t);
|
||||
|
||||
void insert ( T* a )
|
||||
{
|
||||
if(rwsize<vector<T*>::size())
|
||||
{
|
||||
vector<T*>::operator[](rwsize)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<T*>::push_back(a);
|
||||
rwsize=vector<T*>::size();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// insertAt should throw an exception of type RWBoundsErr if you try
|
||||
// to insert out of range
|
||||
//
|
||||
void insertAt ( size_t, T*);
|
||||
|
||||
size_t occurrencesOf(const T*) const;
|
||||
|
||||
T* remove ( const T*);
|
||||
|
||||
size_t removeAll ( const T* );
|
||||
|
||||
T* removeAt ( size_t);
|
||||
|
||||
T* removeFirst ();
|
||||
|
||||
T* removeLast ();
|
||||
|
||||
T* find(const T*) const;
|
||||
size_t entries() const { return rwsize; }
|
||||
|
||||
void append ( T* a )
|
||||
{
|
||||
insert( a );
|
||||
}
|
||||
|
||||
size_t length() const { return rwsize; }
|
||||
|
||||
T*& at ( size_t i )
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector at",rwsize,i));
|
||||
return operator()(i);
|
||||
}
|
||||
|
||||
T*const& at ( size_t i ) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector const at",rwsize,i));
|
||||
return operator()(i);
|
||||
}
|
||||
|
||||
RWBoolean contains ( const T* a) const;
|
||||
|
||||
RWBoolean isEmpty()const {return rwsize==0;}
|
||||
|
||||
T* first() const
|
||||
{
|
||||
if(!rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector front",rwsize,0));
|
||||
return vector<T*>::front();
|
||||
}
|
||||
|
||||
T* last() const
|
||||
{
|
||||
if(rwsize)
|
||||
return vector<T*>::operator[](rwsize-1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void prepend(T* const ptr)
|
||||
{
|
||||
vector<T*>::insert(vector<T*>::begin(),ptr);
|
||||
rwsize++;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class T > void RWTPtrOrderedVector<T>::clear()
|
||||
{
|
||||
//vector<T*>::erase(vector<T*>::begin(), vector<T*>::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T > void RWTPtrOrderedVector<T>::clearAndDestroy()
|
||||
{
|
||||
int sz;
|
||||
set<T*,greater<T*> > tmp;
|
||||
for (sz=0;sz<rwsize;sz++)
|
||||
{
|
||||
T* current;
|
||||
current=vector<T*>::operator[](sz);
|
||||
if ( current )
|
||||
tmp.insert(current);
|
||||
}
|
||||
typename set<T*,greater<T*> >::iterator it;
|
||||
for(it=tmp.begin();it!=tmp.end();it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
//vector<T*>::erase(vector<T*>::begin(), vector<T*>::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
template<class T> size_t RWTPtrOrderedVector<T>::index( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
for (i = vector<T*>::begin();ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a) return ptn;
|
||||
}
|
||||
return (ptn=~(size_t)0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t RWTPtrOrderedVector<T>::occurrencesOf( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
for (i = vector<T*>::begin();sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (**i==*a) ptn++;
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
RWBoolean RWTPtrOrderedVector<T>::contains( const T* a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn=0;
|
||||
for (i = vector<T*>::begin(); ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T> T* RWTPtrOrderedVector<T>::remove( const T* a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = vector<T*>::begin();ptn<rwsz; i++,ptn++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
T* tmp=*i;
|
||||
vector<T*>::erase(i);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t RWTPtrOrderedVector<T>::removeAll( const T* a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = vector<T*>::begin();sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
vector<T*>::erase(i);
|
||||
rwsize--;
|
||||
i--;
|
||||
ptn++;
|
||||
}
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
// should throw exception if ...
|
||||
template<class T>
|
||||
T* RWTPtrOrderedVector<T>::removeAt( size_t i )
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector removeAt",rwsize,i));
|
||||
iterator it=vector<T*>::begin();
|
||||
int j;
|
||||
for(j=0;j<rwsize && j<i;j++) it++;
|
||||
if(it!=vector<T*>::end())
|
||||
{
|
||||
T* tmp = operator[](i);
|
||||
vector<T*>::erase(it);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* RWTPtrOrderedVector<T>::find(const T* a) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn=0;
|
||||
for (i = vector<T*>::begin(); ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (**i==*a)
|
||||
{
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
template<class T>
|
||||
void RWTPtrOrderedVector<T>::resize(size_t N)
|
||||
{
|
||||
if(N>vector<T*>::size())
|
||||
{
|
||||
int e=N-vector<T*>::size();
|
||||
for(int i=0;i<e;i++)
|
||||
vector<T*>::push_back(0);
|
||||
}
|
||||
else if(N>rwsize)
|
||||
{
|
||||
iterator it=vector<T*>::begin();
|
||||
for(int i=0;i<N;i++,it++);
|
||||
vector<T*>::erase(it,vector<T*>::end());
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void RWTPtrOrderedVector<T>::insertAt ( size_t i, T* a )
|
||||
{
|
||||
if(i<0 || i>rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrOrderedVector insertAt",rwsize,i));
|
||||
if(rwsize<vector<T*>::size())
|
||||
{
|
||||
for(int j=rwsize;j>i;j--)
|
||||
vector<T*>::operator[](j)=vector<T*>::operator[](j-1);
|
||||
vector<T*>::operator[](i)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=vector<T*>::begin();
|
||||
for(int j=0;j<i;j++,it++);
|
||||
vector<T*>::insert(it,a);
|
||||
rwsize++;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* RWTPtrOrderedVector<T>::removeFirst ()
|
||||
{
|
||||
if(rwsize!=0)
|
||||
{
|
||||
T* tmp=vector<T*>::front();
|
||||
vector<T*>::erase(vector<T*>::begin());
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* RWTPtrOrderedVector<T>::removeLast ()
|
||||
{
|
||||
if(rwsize==0) return (T*) 0;
|
||||
|
||||
rwsize--;
|
||||
T* tmp=vector<T*>::operator[](rwsize);
|
||||
vector<T*>::operator[](rwsize)=0;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
#ifndef __tpsrtvec
|
||||
#define __tpsrtvec
|
||||
|
||||
#include "rw/rw2stl_algo.h"
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include <vector.h>
|
||||
#include <algo.h>
|
||||
#endif
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::vector;
|
||||
using std::sort;
|
||||
#endif
|
||||
|
||||
#include "rw/defs.h"
|
||||
|
||||
|
||||
template <class T>
|
||||
class RWTPtrSortedVector : public vector<T*> {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef T** iterator;
|
||||
typedef T* const* const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTPtrSortedVector(size_t n=RWDEFAULT_CAPACITY):vector<T*>(n),rwsize(0)
|
||||
{
|
||||
for(int i=0;i<n;i++)
|
||||
vector<T*>::operator[](i)=0;
|
||||
}
|
||||
|
||||
RWTPtrSortedVector(const RWTPtrSortedVector<T>& v):vector<T*>(v),
|
||||
rwsize(v.rwsize){}
|
||||
|
||||
RWTPtrSortedVector<T>& operator=(const RWTPtrSortedVector<T>& v)
|
||||
{
|
||||
vector<T*>::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
~RWTPtrSortedVector(){}
|
||||
|
||||
T* const& operator [] (size_t n) const
|
||||
{
|
||||
if(n<0 || n>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrSortedVector",rwsize,n));
|
||||
return vector<T*>::operator[](n);
|
||||
}
|
||||
T* const& operator () (size_t n) const
|
||||
{
|
||||
return vector<T*>::operator[](n);
|
||||
}
|
||||
|
||||
T*& at(size_t n )
|
||||
{
|
||||
if(n<0 || n>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrSortedVector",rwsize,n));
|
||||
if(n<vector<T*>::size() && rwsize<=n) rwsize=n+1;
|
||||
return vector<T*>::operator[](n);
|
||||
}
|
||||
|
||||
T* at(size_t n ) const
|
||||
{
|
||||
if(n<0 || n>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrSortedVector",rwsize,n));
|
||||
return vector<T*>::operator[](n);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
vector<T*>::erase(vector<T*>::begin(),vector<T*>::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
void clearAndDestroy ()
|
||||
{
|
||||
size_t sz=0;
|
||||
for(iterator it=vector<T*>::begin();sz<rwsize;it++,sz++)
|
||||
delete *it;
|
||||
vector<T*>::erase(vector<T*>::begin(),vector<T*>::end());
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
T* find (const T* a) const {
|
||||
if(!a || vector<T*>::empty()) return 0;
|
||||
//We are sorted, so try a n log n search
|
||||
int t,d;
|
||||
int u=rwsize,l=0;
|
||||
do
|
||||
{
|
||||
d=(u-l)/2;
|
||||
t=d+l;
|
||||
//this asks *a <= (*(*this)[t] whithout requiring operator<=
|
||||
if(sorter(a,(*this)[t]) || *a==*(*this)[t])
|
||||
u=t;
|
||||
else
|
||||
l=t;
|
||||
}
|
||||
while(d>0);
|
||||
|
||||
if(*(*this)[u]==*a)
|
||||
return (*this)[u];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t entries () const {return rwsize;}
|
||||
|
||||
void insert ( T* a )
|
||||
{
|
||||
if(rwsize<vector<T*>::size())
|
||||
{
|
||||
//We have empty entries
|
||||
iterator it=vector<T*>::begin();
|
||||
for(int i=0;i<rwsize;i++,it++);
|
||||
*it=a;
|
||||
it++;
|
||||
sort(vector<T*>::begin(),it,sorter);
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<T*>::push_back(a);
|
||||
//This makes it a sorted thing;
|
||||
sort(vector<T*>::begin(),vector<T*>::end(),sorter);
|
||||
}
|
||||
rwsize++;
|
||||
}
|
||||
|
||||
size_t index ( const T* a ) const
|
||||
{
|
||||
T*const* ii = vector<T*>::begin();
|
||||
size_t cnt = 0;
|
||||
for (T*const* it = ii;cnt<rwsize; ++it,cnt++)
|
||||
{
|
||||
if ( **it == *a ) return cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
RWBoolean isEmpty () const{return rwsize==0;}
|
||||
|
||||
T* const & first () const
|
||||
{
|
||||
if(!rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTPtrSortedVector first()",rwsize,0));
|
||||
return vector<T*>::front();
|
||||
}
|
||||
|
||||
T* const & last () const
|
||||
{
|
||||
if(rwsize)
|
||||
return vector<T*>::operator[](rwsize-1);
|
||||
else
|
||||
RWTHROW(RWBoundsErr("RWTPtrSortedVector last()",rwsize,0));
|
||||
}
|
||||
|
||||
size_t occurrencesOf(const T* a) const
|
||||
{
|
||||
size_t cnt = 0;
|
||||
size_t sz = 0;
|
||||
for (const_iterator it = vector<T*>::begin();sz<rwsize; ++it,sz++)
|
||||
{
|
||||
if ( **it == *a ) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
T* remove ( const T* a )
|
||||
{
|
||||
iterator retval;
|
||||
size_t sz=0;
|
||||
for(retval=vector<T*>::begin();sz<rwsize;retval++,sz++)
|
||||
if(**retval==*a) break;
|
||||
if(sz<rwsize && retval!=vector<T*>::end())
|
||||
{
|
||||
T* tmp=*retval;
|
||||
vector<T*>::erase(retval);
|
||||
rwsize--;
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t removeAll ( const T* a)
|
||||
{
|
||||
iterator s=vector<T*>::end();
|
||||
iterator e=vector<T*>::end();
|
||||
iterator r;
|
||||
size_t sz=0;
|
||||
int i=0;
|
||||
for(r=vector<T*>::begin();sz<rwsize;r++,sz++)
|
||||
{
|
||||
if(i==0)
|
||||
{
|
||||
if(**r==*a)
|
||||
{
|
||||
s=r;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(**r!=*a)
|
||||
{
|
||||
e=r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
vector<T*>::erase(s,e);
|
||||
rwsize-=i;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
RW2STL_LessPtr<T> sorter;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
template<class T> T* RWTPtrSortedVector<T>::remove( const T* a ) {
|
||||
iterator i = multimap<T,T*>::find (*a);
|
||||
T* retval = (*i).second;
|
||||
erase ( i );
|
||||
return retval;
|
||||
}
|
||||
template<class T> size_t RWTPtrSortedVector<T>::removeAll( const T* a ) {
|
||||
pair<iterator,iterator> p = equal_range ( *a );
|
||||
iterator i1 = p.first;
|
||||
iterator i2 = p.second;
|
||||
iterator i;
|
||||
size_t cnt = 0;
|
||||
for (i=i1; i!=i2; i++) {
|
||||
cout << "remove all : " << (*i).first << " " << (*i).second << endl;
|
||||
erase ( i );
|
||||
cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef __tpvector
|
||||
#define __tpvector
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <vector>
|
||||
#else
|
||||
#include <vector.h>
|
||||
#endif
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
template<class T> class RWTPtrVector : public vector<T*> {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef T** iterator;
|
||||
typedef T* const* const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
RWTPtrVector ();
|
||||
RWTPtrVector (unsigned int n);
|
||||
RWTPtrVector (unsigned int n, T* const & iPtr);
|
||||
RWTPtrVector (const RWTPtrVector<T>& iPtr);
|
||||
~RWTPtrVector(){}
|
||||
// Copy constructor and assignment operator inherited from vector<T*>.
|
||||
RWTPtrVector<T>& operator = (T* p) {
|
||||
for(iterator i = vector<T*>::begin();
|
||||
i != vector<T*>::end();
|
||||
++i) {
|
||||
*i = p;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
T* operator () ( size_t n ) const { return vector<T*>::operator[](n);}
|
||||
T*& operator () ( size_t n ) { return vector<T*>::operator[](n);}
|
||||
//
|
||||
// The [] operator should perform bound checking
|
||||
//
|
||||
T* operator [] ( size_t n ) const { return vector<T*>::operator[](n);}
|
||||
T*& operator [] ( size_t n ) { return vector<T*>::operator[](n);}
|
||||
T* const * data() const { return &(vector<T*>::front()); }
|
||||
size_t length() { return vector<T*>::size();}
|
||||
void reshape( size_t n );
|
||||
};
|
||||
|
||||
#include "rw/tpvector.icc"
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
template<class T> RWTPtrVector<T>::RWTPtrVector (): vector<T*>(){};
|
||||
|
||||
template<class T> RWTPtrVector<T>::RWTPtrVector (unsigned int n) : vector<T*>(n){}
|
||||
|
||||
template<class T> RWTPtrVector<T>::RWTPtrVector (unsigned int n,
|
||||
T* const & iPtr)
|
||||
: vector<T*>(n, iPtr){}
|
||||
|
||||
template<class T> RWTPtrVector<T>::RWTPtrVector (const RWTPtrVector<T>& iPtr)
|
||||
: vector<T*> ( iPtr ){}
|
||||
|
||||
template<class T> void RWTPtrVector<T>::reshape( size_t n )
|
||||
{
|
||||
vector<T*>::resize(n);
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
#ifndef __tvhdict
|
||||
#define __tvhdict
|
||||
|
||||
#include "rw/defs.h"
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <hash_map>
|
||||
#else
|
||||
# if defined(WIN32) && defined(OS_WIN_NT_4_0)
|
||||
// OBJECT Space on WIN32 choose to change this name..
|
||||
# include <hashmap.h>
|
||||
# else
|
||||
# include <hash_map.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "rw/rwstlhash.h"
|
||||
|
||||
template < class K >
|
||||
class Hash {
|
||||
public:
|
||||
Hash(unsigned (*f)( const K& )=HashDefault):fhashfun(f){}
|
||||
unsigned operator()( const K& key ) const;
|
||||
void SetHashFun( unsigned (*hashfun )( const K& ) );
|
||||
private:
|
||||
unsigned (*fhashfun)( const K& );
|
||||
};
|
||||
|
||||
#define hash_dict_t hash_map< K, V, Hash<K>,equal_to<K> >
|
||||
|
||||
template < class K, class V >
|
||||
class RWTValHashDictionary {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef os_hash_table_iterator
|
||||
<
|
||||
OS_PAIR( K, V ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K, V ) )
|
||||
> iterator;
|
||||
typedef os_hash_table_const_iterator
|
||||
<
|
||||
OS_PAIR( K, V ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K, V ) )
|
||||
> const_iterator;
|
||||
#else
|
||||
typedef hash_dict_t::iterator iterator;
|
||||
typedef hash_dict_t::const_iterator const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
RWTValHashDictionary(){}
|
||||
|
||||
RWTValHashDictionary( unsigned (*hashfun)( const K& key) ,size_t n=100):
|
||||
fhm(n,Hash<K>(hashfun),equal_to<K>()){}
|
||||
|
||||
//pair<iterator, RWBoolean> insert(const pair<K,V>& x);
|
||||
V& operator[]( const K& key ) { return fhm[key]; }
|
||||
void clear() { fhm.clear(); }
|
||||
RWBoolean findValue( const K& key, V& retval )
|
||||
{
|
||||
iterator i;
|
||||
i = fhm.find( key );
|
||||
if ( i == fhm.end() ) { return false; }
|
||||
else {
|
||||
retval = (*i).second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
RWBoolean contains(const K& key) const
|
||||
{
|
||||
const_iterator i=fhm.find(key);
|
||||
if(i==fhm.end()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
RWBoolean remove(const K& key)
|
||||
{
|
||||
iterator i=fhm.find(key);
|
||||
if(i==fhm.end()) return false;
|
||||
fhm.erase(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
RWBoolean isEmpty() const
|
||||
{
|
||||
if(fhm.empty()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t entries()const{return fhm.size();}
|
||||
|
||||
void insertKeyAndValue(const K&key,const V&value)
|
||||
{
|
||||
fhm[key]=value;
|
||||
}
|
||||
|
||||
//This is STL, so will not be used by RW
|
||||
iterator begin(){return fhm.begin();}
|
||||
iterator end(){return fhm.end();}
|
||||
|
||||
|
||||
private:
|
||||
hash_dict_t fhm;
|
||||
};
|
||||
|
||||
template < class K, class V >
|
||||
class RWTValHashDictionaryIterator {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef os_hash_table_iterator
|
||||
<
|
||||
OS_PAIR( K, V ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K, V ) )
|
||||
> iterator;
|
||||
typedef os_hash_table_const_iterator
|
||||
<
|
||||
OS_PAIR( K, V ),
|
||||
OS_DIFF_TYPE( OS_PAIR( K, V ) )
|
||||
> const_iterator;
|
||||
#else
|
||||
typedef hash_dict_t::iterator iterator;
|
||||
typedef hash_dict_t::const_iterator const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTValHashDictionaryIterator(RWTValHashDictionary<K,V>&adict):
|
||||
mydict(&adict),it(adict.begin()),defined(false){}
|
||||
|
||||
RWBoolean operator++()
|
||||
{
|
||||
if(!defined) return false;
|
||||
it++;
|
||||
return it!=mydict->end() ? true : false;
|
||||
}
|
||||
|
||||
RWBoolean operator++(int)
|
||||
{
|
||||
if(!defined) return false;
|
||||
it++;
|
||||
return it!=mydict->end() ? true : false;
|
||||
}
|
||||
|
||||
RWBoolean operator()()
|
||||
{
|
||||
if(defined)
|
||||
return operator++();
|
||||
else
|
||||
{
|
||||
defined=true;
|
||||
it=mydict->begin();
|
||||
return it!=mydict->end() ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
K key () const {return (*it).first;}
|
||||
|
||||
void reset (){defined=false;}
|
||||
void reset (RWTValHashDictionary<K,V>&adict)
|
||||
{
|
||||
mydict=adict;
|
||||
defined=false;
|
||||
}
|
||||
V value () const{return (*it).second;}
|
||||
|
||||
private:
|
||||
iterator it;
|
||||
RWTValHashDictionary<K,V>* mydict;
|
||||
RWBoolean defined;
|
||||
};
|
||||
|
||||
#include "rw/tvhdict.icc"
|
||||
|
||||
#undef hash_dict_t
|
||||
|
||||
#endif
|
||||
@@ -1,19 +0,0 @@
|
||||
template< class K >
|
||||
unsigned Hash<K>::operator()( const K& key ) const {
|
||||
return Hash<K>::fhashfun( key );
|
||||
}
|
||||
|
||||
template < class K >
|
||||
void Hash<K>::SetHashFun( unsigned (*hashfun)( const K& ) ) {
|
||||
fhashfun = hashfun;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
template < class K, class V >
|
||||
pair< hash_map< K, V, Hash<K>,equal_to<K> >::iterator, RWBoolean >
|
||||
RWTValHashDictionary<K,V>::insert( const pair<K,V>& x ) {
|
||||
fhm.insert( x );
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,297 +0,0 @@
|
||||
#ifndef __tvordvec
|
||||
#define __tvordvec
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include <vector.h>
|
||||
#include <algo.h>
|
||||
#endif
|
||||
|
||||
#include "rw/defs.h"
|
||||
#include "rw/tvvector.h"
|
||||
|
||||
template<class T> class RWTValOrderedVector : public vector<T>
|
||||
{
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTValOrderedVector(size_t capacity=RWDEFAULT_CAPACITY):vector<T>(capacity),rwsize(0){}
|
||||
|
||||
RWTValOrderedVector(const RWTValOrderedVector<T>& v):
|
||||
vector<T>(v),rwsize(v.rwsize){}
|
||||
|
||||
|
||||
RWTValOrderedVector<T>& operator=(const RWTValOrderedVector<T>& v)
|
||||
{
|
||||
vector<T>::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~RWTValOrderedVector(){}
|
||||
|
||||
T& operator()(size_t i)
|
||||
{
|
||||
//if(i<0 || i>=rwsize)
|
||||
// RWTHROW(RWBoundsErr("RWTValOrderedVector ()",rwsize,i));
|
||||
if(i<vector<T>::size() && rwsize<=i) rwsize=i+1;
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
const T& operator()(size_t i) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector const()",rwsize,i));
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
T& operator[](size_t i)
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector []",rwsize,i));
|
||||
// if(i<vector<T>::size() && rwsize<=i) rwsize=i+1;
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
const T& operator[](size_t i) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector const []",rwsize,i));
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
T& at(size_t n )
|
||||
{
|
||||
if(n<0 || n>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector at",rwsize,n));
|
||||
return operator()(n);
|
||||
}
|
||||
|
||||
T at(size_t n ) const
|
||||
{
|
||||
if(n<0 || n>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector const at",rwsize,n));
|
||||
return operator()(n);
|
||||
}
|
||||
|
||||
void resize(size_t);
|
||||
|
||||
void clear( void )
|
||||
{
|
||||
//vector<T>::erase(vector<T>::begin(), vector<T>::end());
|
||||
for(size_t i=0;i<rwsize;i++)
|
||||
vector<T>::operator[](i)=T();
|
||||
rwsize=0;
|
||||
}
|
||||
|
||||
RWBoolean contains( const T) const;
|
||||
|
||||
size_t length() const{ return rwsize;}
|
||||
|
||||
size_t index ( const T&);
|
||||
|
||||
RWBoolean insert ( const T&);
|
||||
|
||||
//
|
||||
// insertAt should throw an exception of type RWBoundsErr if you try
|
||||
// to insert out of range
|
||||
//
|
||||
void insertAt ( size_t, const T&);
|
||||
|
||||
size_t occurrencesOf ( const T& a ) const;
|
||||
|
||||
RWBoolean remove ( const T& a );
|
||||
|
||||
size_t removeAll ( const T& a );
|
||||
|
||||
T removeAt ( size_t i );
|
||||
|
||||
size_t entries () const { return rwsize; }
|
||||
|
||||
void append ( const T& a )
|
||||
{
|
||||
insert ( a );
|
||||
}
|
||||
|
||||
T first() const
|
||||
{
|
||||
if(!rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector first",rwsize,0));
|
||||
return vector<T>::front();
|
||||
}
|
||||
|
||||
T last() const
|
||||
{
|
||||
if(rwsize)
|
||||
return vector<T>::operator[](rwsize-1);
|
||||
else
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector last",rwsize,0));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
size_t RWTValOrderedVector<T>::index( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
for (i = vector<T>::begin();ptn<rwsize; i++,ptn++)
|
||||
{
|
||||
if (*i==a) return ptn;
|
||||
}
|
||||
return (ptn=~(size_t)0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t RWTValOrderedVector<T>::occurrencesOf( const T& a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
for (i = vector<T>::begin(); sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (*i==a) ptn++;
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
RWBoolean RWTValOrderedVector<T>::remove( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = vector<T>::begin(); sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (*i==a)
|
||||
{
|
||||
vector<T>::erase(i);
|
||||
rwsize--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T> size_t RWTValOrderedVector<T>::removeAll
|
||||
( const T& a )
|
||||
{
|
||||
iterator i;
|
||||
size_t ptn = 0;
|
||||
size_t sz=0;
|
||||
size_t rwsz=rwsize;
|
||||
for (i = vector<T>::begin();sz<rwsz; i++,sz++)
|
||||
{
|
||||
if (*i==a)
|
||||
{
|
||||
vector<T>::erase(i);
|
||||
ptn++;
|
||||
i--;
|
||||
rwsize--;
|
||||
}
|
||||
}
|
||||
return ptn;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T RWTValOrderedVector<T>::removeAt( size_t i )
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector removeAt",rwsize,i));
|
||||
T tmp = operator[](i);
|
||||
iterator it=vector<T>::begin();
|
||||
int j;
|
||||
for(j=0;j<rwsize && j<i;j++) it++;
|
||||
if(it!=vector<T>::end())
|
||||
{
|
||||
vector<T>::erase(it);
|
||||
rwsize--;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void RWTValOrderedVector<T>::resize(size_t N)
|
||||
{
|
||||
if(N>vector<T>::size())
|
||||
{
|
||||
int e=N-vector<T>::size();
|
||||
for(int i=0;i<e;i++)
|
||||
vector<T>::push_back(T());
|
||||
}
|
||||
else if(N>rwsize )
|
||||
{
|
||||
iterator it=vector<T>::begin();
|
||||
for(int i=0;i<N;i++,it++);
|
||||
vector<T>::erase(it,vector<T>::end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
RWBoolean RWTValOrderedVector<T>::contains( const T a ) const
|
||||
{
|
||||
const_iterator i;
|
||||
size_t sz=0;
|
||||
for (i = vector<T>::begin();sz<rwsize; i++,sz++)
|
||||
{
|
||||
if (*i==a) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
RWBoolean RWTValOrderedVector<T>::insert ( const T& a )
|
||||
{
|
||||
if(rwsize<vector<T>::size())
|
||||
{
|
||||
this->vector<T>::operator[](rwsize)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<T>::push_back(a);
|
||||
rwsize=vector<T>::size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void RWTValOrderedVector<T>::insertAt ( size_t i, const T& a )
|
||||
{
|
||||
if(i<0 || i>rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValOrderedVector insertAt",rwsize,i));
|
||||
if(rwsize<vector<T>::size())
|
||||
{
|
||||
for(int j=rwsize;j>i;j--)
|
||||
vector<T>::operator[](j)=this->vector<T>::operator[](j-1);
|
||||
vector<T>::operator[](i)=a;
|
||||
rwsize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=vector<T>::begin();
|
||||
for(int j=0;j<i;j++,it++);
|
||||
vector<T>::insert(it,a);
|
||||
rwsize++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
#ifndef __tvvector
|
||||
#define __tvvector
|
||||
|
||||
#ifndef G4USE_OLDSTL
|
||||
#include <vector>
|
||||
#else
|
||||
#include <vector.h>
|
||||
#endif
|
||||
|
||||
#if defined(G4USE_NAMESPACE)
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
#include "rw/defs.h"
|
||||
|
||||
template<class T> class RWTValVector : public vector<T> {
|
||||
|
||||
#ifdef G4USE_EXPLICIT_TYPES_IN_TEMPLATES
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
#endif
|
||||
|
||||
public:
|
||||
RWTValVector ():rwsize(0){}
|
||||
|
||||
RWTValVector (size_t n):vector<T>(n),rwsize(n){}
|
||||
|
||||
RWTValVector (size_t n, const T& ival):vector<T>(n,ival),rwsize(n){}
|
||||
|
||||
RWTValVector (const RWTValVector<T>& ival):vector<T>(ival),rwsize(ival.rwsize){}
|
||||
|
||||
~RWTValVector(){};
|
||||
|
||||
RWTValVector<T>& operator= ( const RWTValVector<T>& v)
|
||||
{
|
||||
vector<T>::operator=(v);
|
||||
rwsize=v.rwsize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t length() const { return vector<T>::size();}
|
||||
|
||||
T& operator()(size_t i)
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValVector operator()",rwsize,i));
|
||||
if(i<vector<T>::size() && rwsize<i) rwsize=i+1;
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
const T& operator()(size_t i) const { return vector<T>::operator[](i); }
|
||||
|
||||
T& operator[](size_t i)
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValVector operator[]",rwsize,i));
|
||||
if(i<vector<T>::size() && rwsize<i) rwsize=i+1;
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
const T& operator[](size_t i) const
|
||||
{
|
||||
if(i<0 || i>=rwsize)
|
||||
RWTHROW(RWBoundsErr("RWTValVector const operator[]",rwsize,i));
|
||||
return vector<T>::operator[](i);
|
||||
}
|
||||
|
||||
const T* data() const { return &(vector<T>::front()); };
|
||||
|
||||
void resize(size_t N)
|
||||
{
|
||||
if(N>vector<T>::size())
|
||||
{
|
||||
int e=N-vector<T>::size();
|
||||
for(int i=0;i<e;i++)
|
||||
vector<T>::push_back(T());
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator it=vector<T>::begin();
|
||||
for(int i=1;i<=N;i++,it++);
|
||||
vector<T>::erase(it,vector<T>::end());
|
||||
}
|
||||
rwsize=N;
|
||||
}
|
||||
|
||||
void reshape( size_t n )
|
||||
{
|
||||
resize(n);
|
||||
}
|
||||
|
||||
const T& ref(size_t i) const{return vector<T>::operator[](i);}
|
||||
|
||||
private:
|
||||
|
||||
size_t rwsize;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
// wrapper for Objectspace hash map...
|
||||
#include <hashmap.h>
|
||||
|
||||
#ifndef HASHCHARSTAR_H
|
||||
#define HASHCHARSTAR_H
|
||||
inline size_t __stl_hash_string(const char* s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
struct hash<const char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
struct hash<char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
#endif // HASHCHARSTAR_H
|
||||
|
||||
#endif // HASH_MAP_H
|
||||
@@ -1 +1 @@
|
||||
#include<stdio.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1 +1 @@
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
// wrapper for Objectspace hash map...
|
||||
#include <hashmap.h>
|
||||
|
||||
#ifndef HASHCHARSTAR_H
|
||||
#define HASHCHARSTAR_H
|
||||
inline size_t __stl_hash_string(const char* s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
struct hash<const char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
struct hash<char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
#endif // HASHCHARSTAR_H
|
||||
|
||||
#endif // HASH_MAP_H
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
// wrapper for Objectspace hash map...
|
||||
#include <hashmap.h>
|
||||
|
||||
#ifndef HASHCHARSTAR_H
|
||||
#define HASHCHARSTAR_H
|
||||
inline size_t __stl_hash_string(const char* s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
struct hash<const char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
struct hash<char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
#endif // HASHCHARSTAR_H
|
||||
|
||||
#endif // HASH_MAP_H
|
||||
@@ -0,0 +1 @@
|
||||
#include <iomanip.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <iostream.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <strstream.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <iostream.h>
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
// wrapper for Objectspace hash map...
|
||||
#include <hashmap.h>
|
||||
|
||||
#ifndef HASHCHARSTAR_H
|
||||
#define HASHCHARSTAR_H
|
||||
inline size_t __stl_hash_string(const char* s)
|
||||
{
|
||||
unsigned long h = 0;
|
||||
for ( ; *s; ++s)
|
||||
h = 5*h + *s;
|
||||
|
||||
return size_t(h);
|
||||
}
|
||||
struct hash<const char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
struct hash<char*>
|
||||
{
|
||||
size_t operator()(const char* s) const { return __stl_hash_string(s); }
|
||||
};
|
||||
|
||||
#endif // HASHCHARSTAR_H
|
||||
|
||||
#endif // HASH_MAP_H
|
||||
@@ -1,19 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Allocator.hh,v 1.1 1999/01/07 16:09:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Allocator.hh,v 1.3 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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 ----------------
|
||||
@@ -72,11 +70,14 @@ public:
|
||||
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;
|
||||
}
|
||||
/*
|
||||
else if (fUnit->deleted == Deleted) {
|
||||
// G4cerr << "G4Allocator : This object is already deleted" << G4endl;
|
||||
} else {
|
||||
// G4cerr << "G4Allocator: This object is allocated not by G4Allocator"<< G4endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4AllocatorPage.hh,v 1.1 1999/01/07 16:09:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4AllocatorPage.hh,v 1.2 1999/11/16 17:40:22 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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 ----------------
|
||||
@@ -23,7 +21,6 @@
|
||||
#ifndef G4AllocatorPage_h
|
||||
#define G4AllocatorPage_h 1
|
||||
|
||||
//G4AllocatorUnit
|
||||
#include "G4AllocatorUnit.hh"
|
||||
|
||||
template <class Type>
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4AllocatorUnit.hh,v 1.1 1999/01/07 16:09:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4AllocatorUnit.hh,v 1.2 1999/11/16 17:40:22 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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 ----------------
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4DataVector.hh,v 1.1 1999/01/07 16:09:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4DataVector.hh,v 1.4 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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>
|
||||
#include "g4rw/tvordvec.h"
|
||||
|
||||
typedef RWTValOrderedVector<G4double> G4DataVector;
|
||||
typedef G4RWTValOrderedVector<G4double> G4DataVector;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4FastVector.hh,v 1.1 1999/01/07 16:09:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4FastVector.hh,v 1.3 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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
|
||||
// ------------------------------------------------------------
|
||||
@@ -22,8 +20,6 @@
|
||||
#define G4FastVector_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
|
||||
template <class Type, G4int N>
|
||||
class G4FastVector
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4LPhysicsFreeVector.hh,v 1.1 1999/01/07 16:09:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4LPhysicsFreeVector.hh,v 1.2 1999/11/16 17:40:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Class G4LPhysicsFreeVector -- header file
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// 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.
|
||||
@@ -41,42 +43,20 @@ public:
|
||||
|
||||
~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;
|
||||
}
|
||||
void PutValues(size_t binNumber, G4double binValue, G4double dataValue);
|
||||
// G4PhysicsVector has PutValue() but it is inconvenient.
|
||||
// Want to simultaneously fill the bin and data vectors.
|
||||
|
||||
// Note that theEnergy could be energy, momentum, or whatever.
|
||||
inline
|
||||
G4double GetValue(G4double theEnergy, G4bool& isOutRange);
|
||||
// Note that theEnergy could be energy, momentum, or whatever.
|
||||
|
||||
inline
|
||||
void SetVerboseLevel(G4int value)
|
||||
{
|
||||
verboseLevel = value;
|
||||
}
|
||||
void SetVerboseLevel(G4int value);
|
||||
|
||||
inline
|
||||
G4int GetVerboseLevel(G4int)
|
||||
{
|
||||
return verboseLevel;
|
||||
}
|
||||
G4int GetVerboseLevel(G4int);
|
||||
|
||||
inline
|
||||
G4double GetLastEnergy()
|
||||
{
|
||||
return lastEnergy;
|
||||
}
|
||||
G4double GetLastEnergy();
|
||||
|
||||
inline
|
||||
size_t GetLastBin()
|
||||
{
|
||||
return lastBin;
|
||||
}
|
||||
size_t GetLastBin();
|
||||
|
||||
void DumpValues();
|
||||
|
||||
@@ -84,75 +64,10 @@ private:
|
||||
|
||||
G4int verboseLevel;
|
||||
|
||||
// Pure virtual in G4PhysicsVector
|
||||
inline
|
||||
size_t FindBinLocation(G4double theEnergy) const;
|
||||
// Pure virtual in G4PhysicsVector
|
||||
};
|
||||
|
||||
#include "G4LPhysicsFreeVector.icc"
|
||||
|
||||
// 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,121 @@
|
||||
// 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: G4LPhysicsFreeVector.icc,v 1.2 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Class G4LPhysicsFreeVector -- source 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
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// G4PhysicsVector has PutValue() but it is inconvenient.
|
||||
// Want to simultaneously fill the bin and data vectors.
|
||||
|
||||
inline
|
||||
void G4LPhysicsFreeVector::PutValues(size_t binNumber, G4double binValue, G4double dataValue)
|
||||
{
|
||||
binVector(binNumber) = binValue;
|
||||
dataVector(binNumber) = dataValue;
|
||||
}
|
||||
|
||||
// Note that theEnergy could be energy, momentum, or whatever.
|
||||
// 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 << G4endl;
|
||||
|
||||
returnValue = dataVector(0);
|
||||
}
|
||||
else if (theEnergy > edgeMax) {
|
||||
isOutRange = true;
|
||||
|
||||
if (verboseLevel > 1) G4cout << "G4LPhysicsFreeVector::GetValue " <<
|
||||
theEnergy << " " << dataVector(numberOfBin - 1) << " " <<
|
||||
isOutRange << G4endl;
|
||||
|
||||
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 << G4endl;
|
||||
|
||||
returnValue = dataVector(n) + (theEnergy - binVector(n))*dsde;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4LPhysicsFreeVector::SetVerboseLevel(G4int value)
|
||||
{
|
||||
verboseLevel = value;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4LPhysicsFreeVector::GetVerboseLevel(G4int)
|
||||
{
|
||||
return verboseLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4LPhysicsFreeVector::GetLastEnergy()
|
||||
{
|
||||
return lastEnergy;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t G4LPhysicsFreeVector::GetLastBin()
|
||||
{
|
||||
return lastBin;
|
||||
}
|
||||
|
||||
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 << G4endl;
|
||||
return (size_t)n1;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4OrderedTable.hh,v 1.1 1999/01/07 16:09:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4OrderedTable.hh,v 1.4 1999/11/16 17:40:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
@@ -21,16 +21,16 @@
|
||||
#define G4OrderedTable_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include <rw/tvordvec.h>
|
||||
#include <rw/tpordvec.h>
|
||||
#include "g4rw/tvordvec.h"
|
||||
#include "g4rw/tpordvec.h"
|
||||
|
||||
class G4ValVector : public RWTValOrderedVector<G4double>
|
||||
class G4ValVector : public G4RWTValOrderedVector<G4double>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
G4ValVector(size_t capac=RWDEFAULT_CAPACITY)
|
||||
: RWTValOrderedVector<G4double>(capac) {;}
|
||||
G4ValVector(size_t capac=G4RWDEFAULT_CAPACITY)
|
||||
: G4RWTValOrderedVector<G4double>(capac) {;}
|
||||
|
||||
virtual ~G4ValVector() {;}
|
||||
|
||||
@@ -42,6 +42,6 @@ class G4ValVector : public RWTValOrderedVector<G4double>
|
||||
|
||||
};
|
||||
|
||||
typedef RWTPtrOrderedVector<G4ValVector> G4OrderedTable;
|
||||
typedef G4RWTPtrOrderedVector<G4ValVector> G4OrderedTable;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4PhysicsFreeVector.hh,v 1.1 1999/01/07 16:09:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsFreeVector.hh,v 1.2 1999/11/16 17:40:40 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
@@ -14,7 +14,8 @@
|
||||
//
|
||||
// G4PhysicsFreeVector.hh
|
||||
//
|
||||
// Description:
|
||||
// Class 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
|
||||
@@ -22,7 +23,7 @@
|
||||
// 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
|
||||
@@ -58,10 +59,10 @@ class G4PhysicsFreeVector : public G4PhysicsVector
|
||||
// Destructor
|
||||
~G4PhysicsFreeVector();
|
||||
|
||||
// Special PutValue function for PhyiscsFreeVector
|
||||
// Special PutValue function for PhysicsFreeVector
|
||||
void PutValue( size_t binNumber, G4double binValue,
|
||||
G4double dataValue );
|
||||
// To use this method to fill a PhyiscsFreeVector, you have
|
||||
// To use this method to fill a PhysicsFreeVector, 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
|
||||
@@ -74,8 +75,8 @@ class G4PhysicsFreeVector : public G4PhysicsVector
|
||||
};
|
||||
|
||||
|
||||
inline size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const {
|
||||
|
||||
inline size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const
|
||||
{
|
||||
// For G4PhysicsFreeVector, FindBinLocation is implemented using
|
||||
// the binary search algorithm.
|
||||
//
|
||||
@@ -101,17 +102,3 @@ inline size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4PhysicsLinearVector.hh,v 1.1 1999/01/07 16:09:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsLinearVector.hh,v 1.2 1999/11/16 17:40:40 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
@@ -14,12 +14,13 @@
|
||||
//
|
||||
// G4PhysicsLinearVector.hh
|
||||
//
|
||||
// Description:
|
||||
// Class 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
|
||||
@@ -61,8 +62,8 @@ class G4PhysicsLinearVector : public G4PhysicsVector
|
||||
};
|
||||
|
||||
|
||||
inline size_t G4PhysicsLinearVector::FindBinLocation(G4double theEnergy) const {
|
||||
|
||||
inline size_t G4PhysicsLinearVector::FindBinLocation(G4double theEnergy) const
|
||||
{
|
||||
// For G4PhysicsLinearVector, FindBinLocation is implemented using
|
||||
// a simple arithmetic calculation.
|
||||
//
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4PhysicsLogVector.hh,v 1.1 1999/01/07 16:09:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsLogVector.hh,v 1.2 1999/11/16 17:40:41 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
@@ -14,12 +14,13 @@
|
||||
//
|
||||
// G4PhysicsLogVector.hh
|
||||
//
|
||||
// Description:
|
||||
// Class 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
|
||||
@@ -64,8 +65,8 @@ class G4PhysicsLogVector : public G4PhysicsVector
|
||||
};
|
||||
|
||||
|
||||
inline size_t G4PhysicsLogVector::FindBinLocation(G4double theEnergy) const {
|
||||
|
||||
inline size_t G4PhysicsLogVector::FindBinLocation(G4double theEnergy) const
|
||||
{
|
||||
// For G4PhysicsLogVector, FindBinLocation is implemented using
|
||||
// a simple arithmetic calculation.
|
||||
//
|
||||
@@ -80,17 +81,3 @@ inline size_t G4PhysicsLogVector::FindBinLocation(G4double theEnergy) const {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4PhysicsOrderedFreeVector.hh,v 1.1 1999/01/07 16:09:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsOrderedFreeVector.hh,v 1.3 1999/11/16 17:40:41 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// PhysicsOrderedFreeVector Class Definition
|
||||
@@ -20,7 +20,8 @@
|
||||
// > cosmetics (only)
|
||||
// mail: gum@triumf.ca
|
||||
//
|
||||
// Description:
|
||||
// Class 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,
|
||||
@@ -28,7 +29,7 @@
|
||||
// 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
|
||||
@@ -38,7 +39,7 @@
|
||||
// Includes
|
||||
/////////////
|
||||
|
||||
#include <rw/tpordvec.h>
|
||||
#include "g4rw/tpordvec.h"
|
||||
#include "G4PhysicsVector.hh"
|
||||
|
||||
/////////////////////
|
||||
@@ -89,57 +90,6 @@ private:
|
||||
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;
|
||||
}
|
||||
#include "G4PhysicsOrderedFreeVector.icc"
|
||||
|
||||
#endif /* G4PhysicsOrderedFreeVector_h */
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// 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: G4PhysicsOrderedFreeVector.icc,v 1.2 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// PhysicsOrderedFreeVector Class Inline Functions Definitions
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// File: G4PhysicsOrderedFreeVector.icc
|
||||
// Version: 1.0
|
||||
// Author: Juliet Armstrong
|
||||
// mail: gum@triumf.ca
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////
|
||||
// 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] << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4PhysicsTable.hh,v 1.1 1999/01/07 16:09:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsTable.hh,v 1.3 1999/11/16 17:40:42 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
@@ -21,11 +21,11 @@
|
||||
#ifndef G4PhysicsTable_h
|
||||
#define G4PhysicsTable_h 1
|
||||
|
||||
#include <rw/tpordvec.h>
|
||||
#include "g4rw/tpordvec.h"
|
||||
#include "globals.hh"
|
||||
#include "G4PhysicsVector.hh"
|
||||
|
||||
typedef RWTPtrOrderedVector<G4PhysicsVector> G4PhysicsTable;
|
||||
typedef G4RWTPtrOrderedVector<G4PhysicsVector> G4PhysicsTable;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4PhysicsVector.hh,v 1.1 1999/01/07 16:09:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4PhysicsVector.hh,v 1.3 1999/11/16 17:40:43 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
@@ -14,13 +14,14 @@
|
||||
//
|
||||
// G4PhysicsVector.hh
|
||||
//
|
||||
// Description:
|
||||
// Class 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
|
||||
@@ -35,15 +36,15 @@
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include <rw/tpordvec.h>
|
||||
#include "g4rw/tpordvec.h"
|
||||
|
||||
class G4PhysicsVector
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructor and destructor
|
||||
G4PhysicsVector(){};
|
||||
virtual ~G4PhysicsVector(){};
|
||||
G4PhysicsVector();
|
||||
virtual ~G4PhysicsVector();
|
||||
|
||||
// Public functions
|
||||
G4double GetValue(G4double theEnergy, G4bool& isOutRange);
|
||||
@@ -84,11 +85,11 @@ class G4PhysicsVector
|
||||
G4bool IsFilledVectorExist() const;
|
||||
// Is non-empty physics vector already exist?
|
||||
|
||||
void LinkPhysicsTable(RWTPtrOrderedVector<G4PhysicsVector>& theTable);
|
||||
void LinkPhysicsTable(G4RWTPtrOrderedVector<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;
|
||||
const G4RWTPtrOrderedVector<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).
|
||||
@@ -112,7 +113,7 @@ class G4PhysicsVector
|
||||
G4DataVector dataVector; // Vector to keep the crossection/energyloss
|
||||
G4DataVector binVector; // Vector to keep the low edge value of bin
|
||||
|
||||
RWTPtrOrderedVector<G4PhysicsVector>* ptrNextTable;
|
||||
G4RWTPtrOrderedVector<G4PhysicsVector>* ptrNextTable;
|
||||
// Link to the connected physics table
|
||||
|
||||
G4double LinearInterpolation(G4double theEnergy, size_t theLocBin);
|
||||
@@ -125,100 +126,6 @@ class G4PhysicsVector
|
||||
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;
|
||||
}
|
||||
}
|
||||
#include "G4PhysicsVector.icc"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
// 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: G4PhysicsVector.icc,v 1.1 1999/11/16 17:40:46 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4PhysicsVector.icc
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
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 G4RWTPtrOrderedVector<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;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4RotationMatrix.hh,v 1.1 1999/01/07 16:09:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4RotationMatrix.hh,v 1.2 1999/11/16 17:40:47 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4ThreeVector.hh,v 1.1 1999/01/07 16:09:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4ThreeVector.hh,v 1.2 1999/11/16 17:40:47 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Timer.hh,v 1.6 1999/05/24 20:39:23 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Timer.hh,v 1.8 1999/11/23 15:00:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// class G4Timer
|
||||
// Class G4Timer
|
||||
//
|
||||
// Class for timer objects, able to measure elasped user/system process
|
||||
// time.
|
||||
// Class description:
|
||||
//
|
||||
// Class for timer objects, able to measure elasped user/system process time.
|
||||
//
|
||||
// Note: Uses <sys/times.h> & <unistd.h> - POSIX.1 defined
|
||||
//
|
||||
@@ -49,7 +50,7 @@
|
||||
// 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
|
||||
@@ -84,8 +85,7 @@
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "G4Types.hh"
|
||||
|
||||
class ostream;
|
||||
#include "G4ios.hh"
|
||||
|
||||
class G4Timer
|
||||
{
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
tms fStartTimes,fEndTimes;
|
||||
};
|
||||
|
||||
ostream& operator << (ostream& os, const G4Timer& t);
|
||||
G4std::ostream& operator << (G4std::ostream& os, const G4Timer& t);
|
||||
|
||||
// Inline functions:
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4Types.hh,v 1.1 1999/05/24 18:23:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4Types.hh,v 1.3 1999/11/16 17:40:48 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
//
|
||||
// GEANT4 native types
|
||||
@@ -18,9 +18,18 @@
|
||||
|
||||
#include <CLHEP/config/CLHEP.h>
|
||||
|
||||
// Define G4std namespace for standard std.
|
||||
// Needed to allow both ISO/not-ISO ANSI compliant code installations
|
||||
//
|
||||
#ifndef G4USE_STD_NAMESPACE
|
||||
#define G4std
|
||||
#else
|
||||
#define G4std std
|
||||
#endif
|
||||
|
||||
// Typedefs to decouple from library classes
|
||||
// Typedefs for numeric types
|
||||
// [NOTE: Will in future need to be made more sophisticated]
|
||||
//
|
||||
typedef HepDouble G4double;
|
||||
typedef HepFloat G4float;
|
||||
typedef HepInt G4int;
|
||||
@@ -32,4 +41,3 @@ typedef HepInt G4int;
|
||||
typedef long G4long;
|
||||
|
||||
#endif /* G4TYPES_HH */
|
||||
|
||||
|
||||
@@ -1,25 +1,31 @@
|
||||
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4UnitsTable.hh,v 1.2 1999/03/30 13:09:25 maire Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4UnitsTable.hh,v 1.7 1999/11/23 15:00:04 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-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
|
||||
// 13-10-98: Units and symbols printed in fixed length
|
||||
|
||||
// Class description:
|
||||
//
|
||||
// This class maintains a table of Units.
|
||||
// A Unit has a name, a symbol, a value and belong to a category (i.e. its
|
||||
// dimensional definition): Length, Time, Energy, etc...
|
||||
// The Units are grouped by category. The TableOfUnits is a list of categories.
|
||||
// The class BestUnit allow to convert automaticaly a physical quantity
|
||||
// from its internal value into the most appropriate Unit of the same category.
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -28,28 +34,34 @@
|
||||
#define G4UnitsTable_HH
|
||||
|
||||
#include "globals.hh"
|
||||
#include <rw/tpordvec.h>
|
||||
#include "g4rw/tpordvec.h"
|
||||
|
||||
class G4UnitsCategory;
|
||||
typedef RWTPtrOrderedVector<G4UnitsCategory> G4UnitsTable;
|
||||
typedef G4RWTPtrOrderedVector<G4UnitsCategory> G4UnitsTable;
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
class G4UnitDefinition
|
||||
{
|
||||
public:
|
||||
public: // with description
|
||||
|
||||
G4UnitDefinition(G4String name, G4String symbol,G4String category,
|
||||
G4double value);
|
||||
|
||||
public: // without description
|
||||
|
||||
~G4UnitDefinition();
|
||||
G4int operator==(const G4UnitDefinition&) const;
|
||||
G4int operator!=(const G4UnitDefinition&) const;
|
||||
|
||||
private:
|
||||
|
||||
G4UnitDefinition(G4UnitDefinition&);
|
||||
G4UnitDefinition& operator=(const G4UnitDefinition&);
|
||||
|
||||
public:
|
||||
public: // with description
|
||||
|
||||
G4String GetName() {return Name;};
|
||||
G4String GetSymbol() {return SymbolName;};
|
||||
G4double GetValue() {return Value;};
|
||||
@@ -66,6 +78,7 @@ public:
|
||||
static G4String GetCategory(G4String);
|
||||
|
||||
private:
|
||||
|
||||
G4String Name; // SI name
|
||||
G4String SymbolName; // SI symbol
|
||||
G4double Value; // value in the internal system of units
|
||||
@@ -79,21 +92,24 @@ private:
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
typedef RWTPtrOrderedVector<G4UnitDefinition> G4UnitsContainer;
|
||||
typedef G4RWTPtrOrderedVector<G4UnitDefinition> G4UnitsContainer;
|
||||
|
||||
class G4UnitsCategory
|
||||
{
|
||||
public:
|
||||
public: // without description
|
||||
|
||||
G4UnitsCategory(G4String name);
|
||||
~G4UnitsCategory();
|
||||
G4int operator==(const G4UnitsCategory&) const;
|
||||
G4int operator!=(const G4UnitsCategory&) const;
|
||||
|
||||
private:
|
||||
|
||||
G4UnitsCategory(G4UnitsCategory&);
|
||||
G4UnitsCategory& operator=(const G4UnitsCategory&);
|
||||
|
||||
public:
|
||||
public: // without description
|
||||
|
||||
G4String GetName() {return Name;};
|
||||
G4UnitsContainer& GetUnitsList() {return UnitsList;};
|
||||
G4int GetNameMxLen() {return NameMxLen;};
|
||||
@@ -103,6 +119,7 @@ public:
|
||||
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
|
||||
@@ -113,20 +130,29 @@ private:
|
||||
|
||||
class G4BestUnit
|
||||
{
|
||||
public:
|
||||
G4BestUnit(G4double,G4String);
|
||||
public: // with description
|
||||
|
||||
G4BestUnit(G4double internalValue, G4String category);
|
||||
// This constructor converts a physical quantity from its internalValue
|
||||
// into the most appropriate unit of the same category.
|
||||
// In practice it builds an object VU = (newValue, newUnit)
|
||||
|
||||
~G4BestUnit();
|
||||
|
||||
public:
|
||||
public: // without description
|
||||
|
||||
G4double GetValue() {return Value;};
|
||||
G4String GetCategory() {return Category;};
|
||||
size_t GetIndexOfCategory() {return IndexOfCategory;};
|
||||
|
||||
public: // with description
|
||||
|
||||
friend
|
||||
ostream& operator<<(ostream&,G4BestUnit);
|
||||
|
||||
G4std::ostream& operator<<(G4std::ostream&,G4BestUnit VU);
|
||||
// Default format to print the objet VU above.
|
||||
|
||||
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
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4UnitsTest.hh,v 1.1 1999/04/29 17:55:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// -*- C++ -*-
|
||||
// $Id: G4UnitsTest.hh,v 1.4 1999/11/19 09:19:30 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This file is a modified version of SystemOfUnits.h
|
||||
// It is provided for checking the overall 'units coherence' of the
|
||||
// Geant4 kernel.
|
||||
@@ -37,6 +37,7 @@
|
||||
// The others physical constants are defined in the header file :
|
||||
// PhysicalConstants.h
|
||||
//
|
||||
|
||||
// Authors: M.Maire, S.Giani
|
||||
//
|
||||
// History:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user