Index: trunk/source/global/management/include/G4Allocator.hh
===================================================================
--- trunk/source/global/management/include/G4Allocator.hh	(revision 1228)
+++ trunk/source/global/management/include/G4Allocator.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4Allocator.hh,v 1.19 2009/10/29 16:01:28 gcosmo Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4Allocator.hh,v 1.20 2010/03/30 08:17:24 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -137,6 +137,4 @@
       // Rebind allocator to type U
 
-  private:
-
     G4AllocatorPool mem;
       // Pool of elements of sizeof(Type)
Index: trunk/source/global/management/include/G4LPhysicsFreeVector.hh
===================================================================
--- trunk/source/global/management/include/G4LPhysicsFreeVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4LPhysicsFreeVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4LPhysicsFreeVector.hh,v 1.11 2008/09/22 08:26:33 gcosmo Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4LPhysicsFreeVector.hh,v 1.14 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -74,8 +74,4 @@
    G4int GetVerboseLevel(G4int);
 
-   G4double GetLastEnergy();
-
-   size_t GetLastBin();
-
    void DumpValues();
 
Index: trunk/source/global/management/include/G4LPhysicsFreeVector.icc
===================================================================
--- trunk/source/global/management/include/G4LPhysicsFreeVector.icc	(revision 1228)
+++ trunk/source/global/management/include/G4LPhysicsFreeVector.icc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4LPhysicsFreeVector.icc,v 1.14 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: global-V09-02-10 $
+// $Id: G4LPhysicsFreeVector.icc,v 1.17 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -68,15 +68,4 @@
 }
 
-inline
-G4double G4LPhysicsFreeVector::GetLastEnergy()
-{
-   return lastEnergy;
-}
-
-inline
-size_t G4LPhysicsFreeVector::GetLastBin()
-{
-   return lastBin;
-}
 
 inline 
Index: trunk/source/global/management/include/G4PhysicsFreeVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsFreeVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsFreeVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsFreeVector.hh,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsFreeVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -76,5 +76,5 @@
          // the same vector length.
   
-    ~G4PhysicsFreeVector();
+    virtual ~G4PhysicsFreeVector();
          // Destructor
 
Index: trunk/source/global/management/include/G4PhysicsLinearVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsLinearVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsLinearVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLinearVector.hh,v 1.11 2008/09/22 11:37:09 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLinearVector.hh,v 1.13 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/include/G4PhysicsLnVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsLnVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsLnVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLnVector.hh,v 1.13 2008/09/22 11:37:09 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLnVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/include/G4PhysicsLogVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsLogVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsLogVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLogVector.hh,v 1.13 2008/09/22 08:26:33 gcosmo Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLogVector.hh,v 1.15 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/include/G4PhysicsOrderedFreeVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsOrderedFreeVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsOrderedFreeVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsOrderedFreeVector.hh,v 1.12 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsOrderedFreeVector.hh,v 1.14 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 ////////////////////////////////////////////////////////////////////////
Index: trunk/source/global/management/include/G4PhysicsOrderedFreeVector.icc
===================================================================
--- trunk/source/global/management/include/G4PhysicsOrderedFreeVector.icc	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsOrderedFreeVector.icc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsOrderedFreeVector.icc,v 1.9 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: global-V09-02-10 $
+// $Id: G4PhysicsOrderedFreeVector.icc,v 1.11 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 ////////////////////////////////////////////////////////////////////////
Index: trunk/source/global/management/include/G4PhysicsVector.hh
===================================================================
--- trunk/source/global/management/include/G4PhysicsVector.hh	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsVector.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsVector.hh,v 1.25 2009/11/04 11:32:43 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsVector.hh,v 1.31 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -53,5 +53,7 @@
 //    11 May  2009, V.Ivanchenko : Added ComputeSecondDerivatives
 //    19 Jun. 2009, V.Ivanchenko : Removed hidden bin 
-//
+//    22 Dec. 2009  H.Kurashige  : Use pointers to G4PVDataVector
+//    04 May. 2010  H.Kurashige  : Use G4PhysicsVectorCache
+//    28 May  2010  H.Kurashige  : Stop using  pointers to G4PVDataVector
 //---------------------------------------------------------------
 
@@ -65,5 +67,8 @@
 #include <fstream>
 
+#include "G4PhysicsVectorCache.hh"
 #include "G4PhysicsVectorType.hh"
+
+typedef std::vector<G4double> G4PVDataVector;
 
 class G4PhysicsVector 
@@ -86,5 +91,5 @@
          // destructor
 
-    inline G4double Value(G4double theEnergy);
+    G4double Value(G4double theEnergy);
          // Get the cross-section/energy-loss value corresponding to the
          // given energy. An appropriate interpolation is used to calculate
@@ -175,4 +180,10 @@
     friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&);
 
+    
+    G4double GetLastEnergy() const;
+    G4double GetLastValue() const;
+    size_t GetLastBin() const;
+         // Get cache values 
+
   protected:
 
@@ -186,6 +197,4 @@
   protected:
 
-    typedef std::vector<G4double> G4PVDataVector;
-
     G4PhysicsVectorType type;   // The type of PhysicsVector (enumerator)
 
@@ -195,11 +204,9 @@
     size_t numberOfNodes;
 
-    G4double lastEnergy;        // Cache the last input value
-    G4double lastValue;         // Cache the last output value   
-    size_t lastBin;             // Cache the last bin location
-
-    G4PVDataVector dataVector;    // Vector to keep the crossection/energyloss
-    G4PVDataVector binVector;     // Vector to keep energy
-    G4PVDataVector secDerivative; // Vector to keep second derivatives 
+    G4PhysicsVectorCache*  cache;
+
+    G4PVDataVector  dataVector;    // Vector to keep the crossection/energyloss
+    G4PVDataVector  binVector;     // Vector to keep energy
+    G4PVDataVector  secDerivative; // Vector to keep second derivatives 
 
   private:
@@ -207,10 +214,10 @@
     G4bool SplinePossible();
 
-    inline G4double LinearInterpolation();
+    inline G4double LinearInterpolation(G4int lastBin);
          // Linear interpolation function
-    inline G4double SplineInterpolation();
+    inline G4double SplineInterpolation(G4int lastBin);
          // Spline interpolation function
 
-    inline void Interpolation();
+    inline void Interpolation(G4int lastBin);
 
     G4String   comment;
Index: trunk/source/global/management/include/G4PhysicsVector.icc
===================================================================
--- trunk/source/global/management/include/G4PhysicsVector.icc	(revision 1228)
+++ trunk/source/global/management/include/G4PhysicsVector.icc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsVector.icc,v 1.23 2009/11/18 11:42:03 vnivanch Exp $
-// GEANT4 tag $Name: global-V09-02-10 $
+// $Id: G4PhysicsVector.icc,v 1.28 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -44,6 +44,32 @@
 
 inline
+ G4double G4PhysicsVector::GetLastEnergy() const
+{
+  return cache->lastEnergy;	
+}
+
+inline
+ G4double G4PhysicsVector::GetLastValue() const
+{
+   return cache->lastValue;
+}
+
+inline 
+ size_t G4PhysicsVector::GetLastBin() const
+{
+   return cache->lastBin;
+}
+ 
+inline
  G4double G4PhysicsVector::operator[](const size_t binNumber) const
 {
+  return  dataVector[binNumber];
+}
+
+//---------------------------------------------------------------
+
+inline
+ G4double G4PhysicsVector::operator()(const size_t binNumber) const
+{
   return dataVector[binNumber];
 }
@@ -52,12 +78,4 @@
 
 inline
- G4double G4PhysicsVector::operator()(const size_t binNumber) const
-{
-  return dataVector[binNumber];
-}
-
-//---------------------------------------------------------------
-
-inline
  G4double G4PhysicsVector::Energy(const size_t binNumber) const
 {
@@ -76,5 +94,13 @@
 
 inline
- G4double G4PhysicsVector::LinearInterpolation()
+ G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&) 
+{
+  return Value(theEnergy);
+}
+
+//------------------------------------------------
+
+inline
+ G4double G4PhysicsVector::LinearInterpolation(G4int lastBin)
 {
   // Linear interpolation is used to get the value. If the give energy
@@ -84,15 +110,15 @@
   // numberOfBin-1. 
 
-  G4double intplFactor = (lastEnergy-binVector[lastBin]) 
-     / (binVector[lastBin+1]-binVector[lastBin]); // Interpolation factor
+  G4double intplFactor = (cache->lastEnergy-binVector[lastBin]) 
+     / (binVector[lastBin + 1]-binVector[lastBin]); // Interpol. factor
 
   return dataVector[lastBin] +
-         ( dataVector[lastBin+1]-dataVector[lastBin] ) * intplFactor;
-}
-
-//---------------------------------------------------------------
-
-inline
- G4double G4PhysicsVector::SplineInterpolation()
+         ( dataVector[lastBin + 1]-dataVector[lastBin] ) * intplFactor;
+}
+
+//---------------------------------------------------------------
+
+inline
+ G4double G4PhysicsVector::SplineInterpolation(G4int lastBin)
 {
   // Spline interpolation is used to get the value. If the give energy
@@ -106,17 +132,17 @@
   // check bin value
   G4double x1 = binVector[lastBin];
-  G4double x2 = binVector[lastBin+1];
+  G4double x2 = binVector[lastBin + 1];
   G4double delta = x2 - x1;
 
-  G4double a = (x2 - lastEnergy)/delta;
-  G4double b = (lastEnergy - x1)/delta;
+  G4double a = (x2 - cache->lastEnergy)/delta;
+  G4double b = (cache->lastEnergy - x1)/delta;
    
   // Final evaluation of cubic spline polynomial for return   
   G4double y1 = dataVector[lastBin];
-  G4double y2 = dataVector[lastBin+1];
+  G4double y2 = dataVector[lastBin + 1];
 
   G4double res = a*y1 + b*y2 + 
         ( (a*a*a - a)*secDerivative[lastBin] +
-          (b*b*b - b)*secDerivative[lastBin+1] )*delta*delta/6.0;
+          (b*b*b - b)*secDerivative[lastBin + 1] )*delta*delta/6.0;
 
   return res;
@@ -125,52 +151,9 @@
 //---------------------------------------------------------------
 
-inline
- G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&) 
-{
-  return Value(theEnergy);
-}
-
-//---------------------------------------------------------------
-
-inline
- G4double G4PhysicsVector::Value(G4double theEnergy) 
-{
-  // 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.
-
-  if( theEnergy == lastEnergy ) {
-
-  } else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin]) {
-     lastEnergy = theEnergy;
-     Interpolation();
-
-  } else if( theEnergy <= edgeMin ) {
-     lastBin = 0;
-     lastEnergy = edgeMin;
-     lastValue  = dataVector[0];
-
-  } else if( theEnergy >= edgeMax ){
-     lastBin = numberOfNodes-2;
-     lastEnergy = edgeMax;
-     lastValue  = dataVector[numberOfNodes-1];
-
-  } else {
-     lastBin = FindBinLocation(theEnergy); 
-     if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;} 
-     lastEnergy = theEnergy;
-     Interpolation();
-  }
-  return lastValue;        
-}
-
-//---------------------------------------------------------------
-
-inline 
- void G4PhysicsVector::Interpolation()
-{
-  if(useSpline) { lastValue = SplineInterpolation(); }
-  else          { lastValue = LinearInterpolation(); }
+inline 
+ void G4PhysicsVector::Interpolation(G4int lastBin)
+{
+  if(useSpline) { cache->lastValue = SplineInterpolation(lastBin); }
+  else          { cache->lastValue = LinearInterpolation(lastBin); }
 }
 
Index: trunk/source/global/management/include/G4Pow.hh
===================================================================
--- trunk/source/global/management/include/G4Pow.hh	(revision 1228)
+++ trunk/source/global/management/include/G4Pow.hh	(revision 1315)
@@ -24,6 +24,6 @@
 // ********************************************************************
 //
-// $Id: G4Pow.hh,v 1.2 2009/07/03 11:35:07 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4Pow.hh,v 1.5 2010/05/28 08:18:03 vnivanch Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 //
@@ -35,5 +35,8 @@
 //
 // Utility singleton class for the fast computation of log and pow
-// functions 
+// functions. Integer argument should in the interval 0-255, no
+// check is performed inside these methods for performance reasons.
+// Computations with double arguments are fast for the interval
+// 0.5-255.5, standard library is used in the opposite case
 
 // Author: Vladimir Ivanchenko
@@ -109,10 +112,11 @@
 inline G4double G4Pow::A13(G4double A)
 {
-  const G4int maxZ = 256; 
+  const G4double minA = 0.5000001; 
+  const G4double maxA = 255.5; 
 
   G4double res;
-  G4int i = G4int(A + 0.5);
-  if((i >= 1) && (i < maxZ))
+  if((A >= minA) && (A <= maxA))
   {
+    G4int i = G4int(A + 0.5);
     G4double x = (1.0 - A/G4double(i))*onethird;
     res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
@@ -144,10 +148,11 @@
 inline G4double G4Pow::logA(G4double A)
 {
-  const G4int maxZ = 256;
+  const G4double minA = 0.5000001; 
+  const G4double maxA = 255.5; 
 
   G4double res;
-  G4int i = G4int(A + 0.5);
-  if((i >= 1) && (i < maxZ))
+  if((A >= minA) && (A <= maxA))
   {
+    G4int i = G4int(A + 0.5);
     G4double x = 1.0 - A/G4double(i);
     res = lz[i] + x*(1.0 - 0.5*x + onethird*x*x);
Index: trunk/source/global/management/include/G4Version.hh
===================================================================
--- trunk/source/global/management/include/G4Version.hh	(revision 1228)
+++ trunk/source/global/management/include/G4Version.hh	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4Version.hh,v 1.25 2009/11/24 13:51:02 gcosmo Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4Version.hh,v 1.27 2010/06/09 13:52:53 gcosmo Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // Version information
@@ -47,9 +47,9 @@
 
 #ifndef G4VERSION_NUMBER
-#define G4VERSION_NUMBER  930
+#define G4VERSION_NUMBER  940
 #endif
 
 #ifndef G4VERSION_TAG
-#define G4VERSION_TAG "$Name: geant4-09-03 $"
+#define G4VERSION_TAG "$Name: geant4-09-04-beta-cand-01 $"
 #endif
 
@@ -58,6 +58,6 @@
 #include "G4String.hh"
 
-static const G4String G4Version = "$Name: geant4-09-03 $";
-static const G4String G4Date    = "(18-December-2009)";
+static const G4String G4Version = "$Name: geant4-09-04-beta-cand-01 $";
+static const G4String G4Date    = "(25-June-2010)";
 
 #endif
Index: trunk/source/global/management/src/G4LPhysicsFreeVector.cc
===================================================================
--- trunk/source/global/management/src/G4LPhysicsFreeVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4LPhysicsFreeVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4LPhysicsFreeVector.cc,v 1.23 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4LPhysicsFreeVector.cc,v 1.25 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/src/G4PhysicsFreeVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsFreeVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsFreeVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsFreeVector.cc,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsFreeVector.cc,v 1.15 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -93,5 +93,6 @@
 }
 
-void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue, 
+void G4PhysicsFreeVector::PutValue( size_t theBinNumber, 
+				    G4double theBinValue, 
                                     G4double theDataValue )
 {
Index: trunk/source/global/management/src/G4PhysicsLinearVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsLinearVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsLinearVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLinearVector.cc,v 1.15 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLinearVector.cc,v 1.18 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -75,9 +75,14 @@
   binVector.reserve(numberOfNodes);      
 
-  for (size_t i=0; i<numberOfNodes; i++)
-  {
-    binVector.push_back( theEmin + i*dBin );
-    dataVector.push_back(0.0);
-  }
+  binVector.push_back(theEmin);
+  dataVector.push_back(0.0);
+
+  for (size_t i=1; i<numberOfNodes-1; i++)
+    {
+      binVector.push_back( theEmin + i*dBin );
+      dataVector.push_back(0.0);
+    }
+  binVector.push_back(theEmax);
+  dataVector.push_back(0.0);
 
   edgeMin = binVector[0];
Index: trunk/source/global/management/src/G4PhysicsLnVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsLnVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsLnVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLnVector.cc,v 1.18 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLnVector.cc,v 1.21 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -75,9 +75,14 @@
   binVector.reserve(numberOfNodes);      
 
-  for (size_t i=0; i<numberOfNodes; i++)
-  {
-    binVector.push_back(std::exp((baseBin+i)*dBin));
-    dataVector.push_back(0.0);
-  }
+  binVector.push_back(theEmin);
+  dataVector.push_back(0.0);
+
+  for (size_t i=1; i<numberOfNodes-1; i++)
+    {
+      binVector.push_back(std::exp((baseBin+i)*dBin));
+      dataVector.push_back(0.0);
+    }
+  binVector.push_back(theEmax);
+  dataVector.push_back(0.0);
 
   edgeMin = binVector[0];
Index: trunk/source/global/management/src/G4PhysicsLogVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsLogVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsLogVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsLogVector.cc,v 1.22 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsLogVector.cc,v 1.25 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -82,9 +82,14 @@
   static const G4double g4log10 = std::log(10.); 
 
-  for (size_t i=0; i<numberOfNodes; i++)
-  {
-    binVector.push_back(std::exp(g4log10*(baseBin+i)*dBin));
-    dataVector.push_back(0.0);
-  }
+  binVector.push_back(theEmin);
+  dataVector.push_back(0.0);
+
+  for (size_t i=1; i<numberOfNodes-1; i++)
+    {
+      binVector.push_back(std::exp(g4log10*(baseBin+i)*dBin));
+      dataVector.push_back(0.0);
+    }
+  binVector.push_back(theEmax);
+  dataVector.push_back(0.0);
 
   edgeMin = binVector[0];
Index: trunk/source/global/management/src/G4PhysicsOrderedFreeVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsOrderedFreeVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsOrderedFreeVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsOrderedFreeVector.cc,v 1.13 2009/06/25 10:05:26 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsOrderedFreeVector.cc,v 1.15 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 ////////////////////////////////////////////////////////////////////////
Index: trunk/source/global/management/src/G4PhysicsVector.cc
===================================================================
--- trunk/source/global/management/src/G4PhysicsVector.cc	(revision 1228)
+++ trunk/source/global/management/src/G4PhysicsVector.cc	(revision 1315)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4PhysicsVector.cc,v 1.41 2009/12/07 09:21:27 vnivanch Exp $
-// GEANT4 tag $Name: geant4-09-03 $
+// $Id: G4PhysicsVector.cc,v 1.46 2010/05/28 05:13:43 kurasige Exp $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
@@ -49,4 +49,7 @@
 //                                    algorithm
 //    19 Jun. 2009, V.Ivanchenko : removed hidden bin 
+//    17 Nov. 2009, H.Kurashige   : use pointer for DataVector
+//    04 May  2010  H.Kurashige   : use G4PhyscisVectorCache
+//    28 May  2010  H.Kurashige  : Stop using  pointers to G4PVDataVector
 // --------------------------------------------------------------
 
@@ -59,11 +62,15 @@
  : type(T_G4PhysicsVector),
    edgeMin(0.), edgeMax(0.), numberOfNodes(0),
-   lastEnergy(-DBL_MAX), lastValue(0.), lastBin(0), useSpline(spline)
-{}
+   useSpline(spline)
+{
+  cache      = new G4PhysicsVectorCache();
+}
 
 // --------------------------------------------------------------
 
 G4PhysicsVector::~G4PhysicsVector() 
-{}
+{
+  delete cache; cache =0;
+}
 
 // --------------------------------------------------------------
@@ -71,4 +78,5 @@
 G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right)
 {
+  cache      = new G4PhysicsVectorCache();
   CopyData(right);
 }
@@ -116,12 +124,23 @@
   edgeMax = vec.edgeMax;
   numberOfNodes = vec.numberOfNodes;
-  lastEnergy = vec.lastEnergy;
-  lastValue = vec.lastValue;
-  lastBin = vec.lastBin;
-  dataVector = vec.dataVector;
-  binVector = vec.binVector;
+  cache->lastEnergy = vec.GetLastEnergy();
+  cache->lastValue = vec.GetLastValue();
+  cache->lastBin = vec.GetLastBin();
   useSpline = vec.useSpline;
   comment = vec.comment;
-  secDerivative = vec.secDerivative;
+
+  size_t i;
+  dataVector.clear();
+  for(i=0; i<(vec.dataVector).size(); i++){ 
+    dataVector.push_back( (vec.dataVector)[i] );
+  }
+  binVector.clear();
+  for(i=0; i<(vec.binVector).size(); i++){ 
+    binVector.push_back( (vec.binVector)[i] );
+  }
+  secDerivative.clear();
+  for(i=0; i<(vec.secDerivative).size(); i++){ 
+    secDerivative.push_back( (vec.secDerivative)[i] );
+  }
 }
 
@@ -171,7 +190,7 @@
 {
   // clear properties;
-  lastEnergy=-DBL_MAX;
-  lastValue =0.;
-  lastBin   =0;
+  cache->lastEnergy=-DBL_MAX;
+  cache->lastValue =0.;
+  cache->lastBin   =0;
   dataVector.clear();
   binVector.clear();
@@ -253,6 +272,6 @@
   edgeMin *= factorE;
   edgeMax *= factorE;
-  lastEnergy *= factorE;
-  lastValue  *= factorV;
+  cache->lastEnergy = factorE*(cache->lastEnergy);
+  cache->lastValue  = factorV*(cache->lastValue);
 }
 
@@ -293,5 +312,5 @@
   {
     sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
-    p = sig*secDerivative[i-1] + 2.0;
+    p = sig*(secDerivative[i-1]) + 2.0;
     secDerivative[i] = (sig - 1.0)/p;
     u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
@@ -457,2 +476,37 @@
   return out;
 }
+
+//---------------------------------------------------------------
+
+G4double G4PhysicsVector::Value(G4double theEnergy) 
+{
+  // 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.
+
+  if( theEnergy == cache->lastEnergy ) {
+
+  } else if( theEnergy < cache->lastEnergy
+	&&   theEnergy >= binVector[cache->lastBin]) {
+     cache->lastEnergy = theEnergy;
+     Interpolation(cache->lastBin);
+
+  } else if( theEnergy <= edgeMin ) {
+     cache->lastBin = 0;
+     cache->lastEnergy = edgeMin;
+     cache->lastValue  = dataVector[0];
+
+  } else if( theEnergy >= edgeMax ){
+     cache->lastBin = numberOfNodes-1;
+     cache->lastEnergy = edgeMax;
+     cache->lastValue  = dataVector[cache->lastBin];
+
+  } else {
+     cache->lastBin = FindBinLocation(theEnergy); 
+     cache->lastEnergy = theEnergy;
+     Interpolation(cache->lastBin);
+  }
+  return cache->lastValue;        
+}
+
Index: trunk/source/global/management/test/AllocVectorTest.cc
===================================================================
--- trunk/source/global/management/test/AllocVectorTest.cc	(revision 1228)
+++ trunk/source/global/management/test/AllocVectorTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: AllocVectorTest.cc,v 1.2 2006/06/29 19:04:45 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/AllocatorTest.cc
===================================================================
--- trunk/source/global/management/test/AllocatorTest.cc	(revision 1228)
+++ trunk/source/global/management/test/AllocatorTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: AllocatorTest.cc,v 1.2 2006/06/29 19:04:47 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/DeallocatorTest.cc
===================================================================
--- trunk/source/global/management/test/DeallocatorTest.cc	(revision 1228)
+++ trunk/source/global/management/test/DeallocatorTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: DeallocatorTest.cc,v 1.3 2006/06/29 19:04:49 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/G4UnitsTest.cc
===================================================================
--- trunk/source/global/management/test/G4UnitsTest.cc	(revision 1228)
+++ trunk/source/global/management/test/G4UnitsTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: G4UnitsTest.cc,v 1.6 2006/06/29 19:04:53 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/LimitsTest.cc
===================================================================
--- trunk/source/global/management/test/LimitsTest.cc	(revision 1228)
+++ trunk/source/global/management/test/LimitsTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: LimitsTest.cc,v 1.2 2006/06/29 19:04:55 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/OrderedTableTest.cc
===================================================================
--- trunk/source/global/management/test/OrderedTableTest.cc	(revision 1228)
+++ trunk/source/global/management/test/OrderedTableTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: OrderedTableTest.cc,v 1.7 2006/06/29 19:04:58 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/PhysicsTableTest.cc
===================================================================
--- trunk/source/global/management/test/PhysicsTableTest.cc	(revision 1228)
+++ trunk/source/global/management/test/PhysicsTableTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: PhysicsTableTest.cc,v 1.6 2006/06/29 19:05:00 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/TimerTest.cc
===================================================================
--- trunk/source/global/management/test/TimerTest.cc	(revision 1228)
+++ trunk/source/global/management/test/TimerTest.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: TimerTest.cc,v 1.2 2006/06/29 19:05:02 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 // 
Index: trunk/source/global/management/test/testPhysicsOrderedFreeVector.cc
===================================================================
--- trunk/source/global/management/test/testPhysicsOrderedFreeVector.cc	(revision 1228)
+++ trunk/source/global/management/test/testPhysicsOrderedFreeVector.cc	(revision 1315)
@@ -26,5 +26,5 @@
 //
 // $Id: testPhysicsOrderedFreeVector.cc,v 1.6 2006/06/29 19:05:05 gunter Exp $
-// GEANT4 tag $Name: geant4-09-02-ref-02 $
+// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
 //
 #include "globals.hh"
