- Timestamp:
- Nov 19, 2009, 3:40:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/global/management/include/G4PhysicsVector.icc
r1058 r1193 25 25 // 26 26 // 27 // $Id: G4PhysicsVector.icc,v 1. 17 2008/09/22 08:26:33 gcosmoExp $28 // GEANT4 tag $Name: g eant4-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 $ 29 29 // 30 30 // … … 59 59 //--------------------------------------------------------------- 60 60 61 inline 62 G4double G4PhysicsVector::Energy(const size_t binNumber) const 63 { 64 return binVector[binNumber]; 65 } 66 67 //--------------------------------------------------------------- 68 61 69 inline 62 70 size_t G4PhysicsVector::GetVectorLength() const 63 71 { 64 return numberOf Bin;72 return numberOfNodes; 65 73 } 66 74 … … 94 102 // numberOfBin-1. 95 103 96 if( !secDerivative) { FillSecondDerivatives(); }104 if(0 == secDerivative.size() ) { FillSecondDerivatives(); } 97 105 98 106 // 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; 103 113 104 114 // Final evaluation of cubic spline polynomial for return … … 107 117 108 118 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; 111 121 112 122 return res; … … 117 127 inline 118 128 G4double G4PhysicsVector::GetValue(G4double theEnergy, G4bool&) 129 { 130 return Value(theEnergy); 131 } 132 133 //--------------------------------------------------------------- 134 135 inline 136 G4double G4PhysicsVector::Value(G4double theEnergy) 119 137 { 120 138 // Use cache for speed up - check if the value 'theEnergy' is same as the … … 134 152 lastValue = dataVector[0]; 135 153 136 } else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin-1]) {137 lastBin--;138 lastEnergy = theEnergy;139 Interpolation();140 141 154 } else if( theEnergy >= edgeMax ){ 142 lastBin = numberOf Bin-1;155 lastBin = numberOfNodes-2; 143 156 lastEnergy = edgeMax; 144 lastValue = dataVector[ lastBin];157 lastValue = dataVector[numberOfNodes-1]; 145 158 146 159 } else { 147 160 lastBin = FindBinLocation(theEnergy); 161 if(lastBin >= numberOfNodes-1) {lastBin = numberOfNodes-2;} 148 162 lastEnergy = theEnergy; 149 163 Interpolation(); … … 167 181 { 168 182 dataVector[binNumber] = theValue; 169 170 // Fill the bin which is hidden to user with theValue. This is to171 // handle correctly when Energy=theEmax in getValue.172 173 if(binNumber==numberOfBin-1) { dataVector[binNumber+1] = theValue; }174 183 } 175 184 … … 181 190 G4bool status=false; 182 191 183 if(numberOf Bin> 0) { status=true; }192 if(numberOfNodes > 0) { status=true; } 184 193 return status; 185 194 }
Note: See TracChangeset
for help on using the changeset viewer.