Ignore:
Timestamp:
Nov 19, 2009, 3:40:00 PM (15 years ago)
Author:
garnier
Message:

CVS update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/global/management/include/G4PhysicsVector.icc

    r1058 r1193  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.icc,v 1.17 2008/09/22 08:26:33 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4PhysicsVector.icc,v 1.23 2009/11/18 11:42:03 vnivanch Exp $
     28// GEANT4 tag $Name: global-V09-02-10 $
    2929//
    3030//
     
    5959//---------------------------------------------------------------
    6060
     61inline
     62 G4double G4PhysicsVector::Energy(const size_t binNumber) const
     63{
     64  return binVector[binNumber];
     65}
     66
     67//---------------------------------------------------------------
     68
    6169inline
    6270 size_t G4PhysicsVector::GetVectorLength() const
    6371{
    64   return numberOfBin;
     72  return numberOfNodes;
    6573}
    6674
     
    94102  // numberOfBin-1.
    95103
    96   if( !secDerivative ) { FillSecondDerivatives(); }
     104  if(0 == secDerivative.size() ) { FillSecondDerivatives(); }
    97105
    98106  // check bin value
    99   G4double delta = binVector[lastBin+1] - binVector[lastBin];
    100 
    101   G4double a = (binVector[lastBin+1] - lastEnergy)/delta;
    102   G4double b = (lastEnergy - binVector[lastBin])/delta;
     107  G4double x1 = binVector[lastBin];
     108  G4double x2 = binVector[lastBin+1];
     109  G4double delta = x2 - x1;
     110
     111  G4double a = (x2 - lastEnergy)/delta;
     112  G4double b = (lastEnergy - x1)/delta;
    103113   
    104114  // Final evaluation of cubic spline polynomial for return   
     
    107117
    108118  G4double res = a*y1 + b*y2 +
    109         ((a*a*a - a)*secDerivative[lastBin] +
    110          (b*b*b - b)*secDerivative[lastBin+1])*delta*delta/6.0  ;
     119        ( (a*a*a - a)*secDerivative[lastBin] +
     120          (b*b*b - b)*secDerivative[lastBin+1] )*delta*delta/6.0;
    111121
    112122  return res;
     
    117127inline
    118128 G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&)
     129{
     130  return Value(theEnergy);
     131}
     132
     133//---------------------------------------------------------------
     134
     135inline
     136 G4double G4PhysicsVector::Value(G4double theEnergy)
    119137{
    120138  // Use cache for speed up - check if the value 'theEnergy' is same as the
     
    134152     lastValue  = dataVector[0];
    135153
    136   } else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin-1]) {
    137      lastBin--;
    138      lastEnergy = theEnergy;
    139      Interpolation();
    140 
    141154  } else if( theEnergy >= edgeMax ){
    142      lastBin = numberOfBin-1;
     155     lastBin = numberOfNodes-2;
    143156     lastEnergy = edgeMax;
    144      lastValue  = dataVector[lastBin];
     157     lastValue  = dataVector[numberOfNodes-1];
    145158
    146159  } else {
    147160     lastBin = FindBinLocation(theEnergy);
     161     if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;}
    148162     lastEnergy = theEnergy;
    149163     Interpolation();
     
    167181{
    168182  dataVector[binNumber] = theValue;
    169 
    170   // Fill the bin which is hidden to user with theValue. This is to
    171   // handle correctly when Energy=theEmax in getValue.
    172 
    173   if(binNumber==numberOfBin-1) { dataVector[binNumber+1] = theValue; }
    174183}
    175184
     
    181190  G4bool status=false;
    182191
    183   if(numberOfBin > 0) { status=true; }
     192  if(numberOfNodes > 0) { status=true; }
    184193  return status;
    185194}
Note: See TracChangeset for help on using the changeset viewer.