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/src/G4PhysicsVector.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4PhysicsVector.cc,v 1.41 2009/12/07 09:21:27 vnivanch Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4PhysicsVector.cc,v 1.46 2010/05/28 05:13:43 kurasige Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030//
     
    4949//                                    algorithm
    5050//    19 Jun. 2009, V.Ivanchenko : removed hidden bin
     51//    17 Nov. 2009, H.Kurashige   : use pointer for DataVector
     52//    04 May  2010  H.Kurashige   : use G4PhyscisVectorCache
     53//    28 May  2010  H.Kurashige  : Stop using  pointers to G4PVDataVector
    5154// --------------------------------------------------------------
    5255
     
    5962 : type(T_G4PhysicsVector),
    6063   edgeMin(0.), edgeMax(0.), numberOfNodes(0),
    61    lastEnergy(-DBL_MAX), lastValue(0.), lastBin(0), useSpline(spline)
    62 {}
     64   useSpline(spline)
     65{
     66  cache      = new G4PhysicsVectorCache();
     67}
    6368
    6469// --------------------------------------------------------------
    6570
    6671G4PhysicsVector::~G4PhysicsVector()
    67 {}
     72{
     73  delete cache; cache =0;
     74}
    6875
    6976// --------------------------------------------------------------
     
    7178G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right)
    7279{
     80  cache      = new G4PhysicsVectorCache();
    7381  CopyData(right);
    7482}
     
    116124  edgeMax = vec.edgeMax;
    117125  numberOfNodes = vec.numberOfNodes;
    118   lastEnergy = vec.lastEnergy;
    119   lastValue = vec.lastValue;
    120   lastBin = vec.lastBin;
    121   dataVector = vec.dataVector;
    122   binVector = vec.binVector;
     126  cache->lastEnergy = vec.GetLastEnergy();
     127  cache->lastValue = vec.GetLastValue();
     128  cache->lastBin = vec.GetLastBin();
    123129  useSpline = vec.useSpline;
    124130  comment = vec.comment;
    125   secDerivative = vec.secDerivative;
     131
     132  size_t i;
     133  dataVector.clear();
     134  for(i=0; i<(vec.dataVector).size(); i++){
     135    dataVector.push_back( (vec.dataVector)[i] );
     136  }
     137  binVector.clear();
     138  for(i=0; i<(vec.binVector).size(); i++){
     139    binVector.push_back( (vec.binVector)[i] );
     140  }
     141  secDerivative.clear();
     142  for(i=0; i<(vec.secDerivative).size(); i++){
     143    secDerivative.push_back( (vec.secDerivative)[i] );
     144  }
    126145}
    127146
     
    171190{
    172191  // clear properties;
    173   lastEnergy=-DBL_MAX;
    174   lastValue =0.;
    175   lastBin   =0;
     192  cache->lastEnergy=-DBL_MAX;
     193  cache->lastValue =0.;
     194  cache->lastBin   =0;
    176195  dataVector.clear();
    177196  binVector.clear();
     
    253272  edgeMin *= factorE;
    254273  edgeMax *= factorE;
    255   lastEnergy *= factorE;
    256   lastValue  *= factorV;
     274  cache->lastEnergy = factorE*(cache->lastEnergy);
     275  cache->lastValue  = factorV*(cache->lastValue);
    257276}
    258277
     
    293312  {
    294313    sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
    295     p = sig*secDerivative[i-1] + 2.0;
     314    p = sig*(secDerivative[i-1]) + 2.0;
    296315    secDerivative[i] = (sig - 1.0)/p;
    297316    u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
     
    457476  return out;
    458477}
     478
     479//---------------------------------------------------------------
     480
     481G4double G4PhysicsVector::Value(G4double theEnergy)
     482{
     483  // Use cache for speed up - check if the value 'theEnergy' is same as the
     484  // last call. If it is same, then use the last bin location. Also the
     485  // value 'theEnergy' lies between the last energy and low edge of of the
     486  // bin of last call, then the last bin location is used.
     487
     488  if( theEnergy == cache->lastEnergy ) {
     489
     490  } else if( theEnergy < cache->lastEnergy
     491        &&   theEnergy >= binVector[cache->lastBin]) {
     492     cache->lastEnergy = theEnergy;
     493     Interpolation(cache->lastBin);
     494
     495  } else if( theEnergy <= edgeMin ) {
     496     cache->lastBin = 0;
     497     cache->lastEnergy = edgeMin;
     498     cache->lastValue  = dataVector[0];
     499
     500  } else if( theEnergy >= edgeMax ){
     501     cache->lastBin = numberOfNodes-1;
     502     cache->lastEnergy = edgeMax;
     503     cache->lastValue  = dataVector[cache->lastBin];
     504
     505  } else {
     506     cache->lastBin = FindBinLocation(theEnergy);
     507     cache->lastEnergy = theEnergy;
     508     Interpolation(cache->lastBin);
     509  }
     510  return cache->lastValue;       
     511}
     512
Note: See TracChangeset for help on using the changeset viewer.