Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

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

    r1193 r1315  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.icc,v 1.23 2009/11/18 11:42:03 vnivanch Exp $
    28 // GEANT4 tag $Name: global-V09-02-10 $
     27// $Id: G4PhysicsVector.icc,v 1.28 2010/05/28 05:13:43 kurasige Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030//
     
    4444
    4545inline
     46 G4double G4PhysicsVector::GetLastEnergy() const
     47{
     48  return cache->lastEnergy;     
     49}
     50
     51inline
     52 G4double G4PhysicsVector::GetLastValue() const
     53{
     54   return cache->lastValue;
     55}
     56
     57inline
     58 size_t G4PhysicsVector::GetLastBin() const
     59{
     60   return cache->lastBin;
     61}
     62 
     63inline
    4664 G4double G4PhysicsVector::operator[](const size_t binNumber) const
    4765{
     66  return  dataVector[binNumber];
     67}
     68
     69//---------------------------------------------------------------
     70
     71inline
     72 G4double G4PhysicsVector::operator()(const size_t binNumber) const
     73{
    4874  return dataVector[binNumber];
    4975}
     
    5278
    5379inline
    54  G4double G4PhysicsVector::operator()(const size_t binNumber) const
    55 {
    56   return dataVector[binNumber];
    57 }
    58 
    59 //---------------------------------------------------------------
    60 
    61 inline
    6280 G4double G4PhysicsVector::Energy(const size_t binNumber) const
    6381{
     
    7694
    7795inline
    78  G4double G4PhysicsVector::LinearInterpolation()
     96 G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&)
     97{
     98  return Value(theEnergy);
     99}
     100
     101//------------------------------------------------
     102
     103inline
     104 G4double G4PhysicsVector::LinearInterpolation(G4int lastBin)
    79105{
    80106  // Linear interpolation is used to get the value. If the give energy
     
    84110  // numberOfBin-1.
    85111
    86   G4double intplFactor = (lastEnergy-binVector[lastBin])
    87      / (binVector[lastBin+1]-binVector[lastBin]); // Interpolation factor
     112  G4double intplFactor = (cache->lastEnergy-binVector[lastBin])
     113     / (binVector[lastBin + 1]-binVector[lastBin]); // Interpol. factor
    88114
    89115  return dataVector[lastBin] +
    90          ( dataVector[lastBin+1]-dataVector[lastBin] ) * intplFactor;
    91 }
    92 
    93 //---------------------------------------------------------------
    94 
    95 inline
    96  G4double G4PhysicsVector::SplineInterpolation()
     116         ( dataVector[lastBin + 1]-dataVector[lastBin] ) * intplFactor;
     117}
     118
     119//---------------------------------------------------------------
     120
     121inline
     122 G4double G4PhysicsVector::SplineInterpolation(G4int lastBin)
    97123{
    98124  // Spline interpolation is used to get the value. If the give energy
     
    106132  // check bin value
    107133  G4double x1 = binVector[lastBin];
    108   G4double x2 = binVector[lastBin+1];
     134  G4double x2 = binVector[lastBin + 1];
    109135  G4double delta = x2 - x1;
    110136
    111   G4double a = (x2 - lastEnergy)/delta;
    112   G4double b = (lastEnergy - x1)/delta;
     137  G4double a = (x2 - cache->lastEnergy)/delta;
     138  G4double b = (cache->lastEnergy - x1)/delta;
    113139   
    114140  // Final evaluation of cubic spline polynomial for return   
    115141  G4double y1 = dataVector[lastBin];
    116   G4double y2 = dataVector[lastBin+1];
     142  G4double y2 = dataVector[lastBin + 1];
    117143
    118144  G4double res = a*y1 + b*y2 +
    119145        ( (a*a*a - a)*secDerivative[lastBin] +
    120           (b*b*b - b)*secDerivative[lastBin+1] )*delta*delta/6.0;
     146          (b*b*b - b)*secDerivative[lastBin + 1] )*delta*delta/6.0;
    121147
    122148  return res;
     
    125151//---------------------------------------------------------------
    126152
    127 inline
    128  G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&)
    129 {
    130   return Value(theEnergy);
    131 }
    132 
    133 //---------------------------------------------------------------
    134 
    135 inline
    136  G4double G4PhysicsVector::Value(G4double theEnergy)
    137 {
    138   // Use cache for speed up - check if the value 'theEnergy' is same as the
    139   // last call. If it is same, then use the last bin location. Also the
    140   // value 'theEnergy' lies between the last energy and low edge of of the
    141   // bin of last call, then the last bin location is used.
    142 
    143   if( theEnergy == lastEnergy ) {
    144 
    145   } else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin]) {
    146      lastEnergy = theEnergy;
    147      Interpolation();
    148 
    149   } else if( theEnergy <= edgeMin ) {
    150      lastBin = 0;
    151      lastEnergy = edgeMin;
    152      lastValue  = dataVector[0];
    153 
    154   } else if( theEnergy >= edgeMax ){
    155      lastBin = numberOfNodes-2;
    156      lastEnergy = edgeMax;
    157      lastValue  = dataVector[numberOfNodes-1];
    158 
    159   } else {
    160      lastBin = FindBinLocation(theEnergy);
    161      if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;}
    162      lastEnergy = theEnergy;
    163      Interpolation();
    164   }
    165   return lastValue;       
    166 }
    167 
    168 //---------------------------------------------------------------
    169 
    170 inline
    171  void G4PhysicsVector::Interpolation()
    172 {
    173   if(useSpline) { lastValue = SplineInterpolation(); }
    174   else          { lastValue = LinearInterpolation(); }
     153inline
     154 void G4PhysicsVector::Interpolation(G4int lastBin)
     155{
     156  if(useSpline) { cache->lastValue = SplineInterpolation(lastBin); }
     157  else          { cache->lastValue = LinearInterpolation(lastBin); }
    175158}
    176159
Note: See TracChangeset for help on using the changeset viewer.