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;        
+}
+
