Changeset 1315 for trunk/source/global/management/src/G4PhysicsVector.cc
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/global/management/src/G4PhysicsVector.cc
r1228 r1315 25 25 // 26 26 // 27 // $Id: G4PhysicsVector.cc,v 1.4 1 2009/12/07 09:21:27 vnivanchExp $28 // GEANT4 tag $Name: geant4-09-0 3$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 $ 29 29 // 30 30 // … … 49 49 // algorithm 50 50 // 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 51 54 // -------------------------------------------------------------- 52 55 … … 59 62 : type(T_G4PhysicsVector), 60 63 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 } 63 68 64 69 // -------------------------------------------------------------- 65 70 66 71 G4PhysicsVector::~G4PhysicsVector() 67 {} 72 { 73 delete cache; cache =0; 74 } 68 75 69 76 // -------------------------------------------------------------- … … 71 78 G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right) 72 79 { 80 cache = new G4PhysicsVectorCache(); 73 81 CopyData(right); 74 82 } … … 116 124 edgeMax = vec.edgeMax; 117 125 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(); 123 129 useSpline = vec.useSpline; 124 130 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 } 126 145 } 127 146 … … 171 190 { 172 191 // 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; 176 195 dataVector.clear(); 177 196 binVector.clear(); … … 253 272 edgeMin *= factorE; 254 273 edgeMax *= factorE; 255 lastEnergy *= factorE;256 lastValue *= factorV;274 cache->lastEnergy = factorE*(cache->lastEnergy); 275 cache->lastValue = factorV*(cache->lastValue); 257 276 } 258 277 … … 293 312 { 294 313 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; 296 315 secDerivative[i] = (sig - 1.0)/p; 297 316 u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i]) … … 457 476 return out; 458 477 } 478 479 //--------------------------------------------------------------- 480 481 G4double 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.