Changeset 1315 for trunk/source/materials/src/G4MaterialPropertyVector.cc
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/materials/src/G4MaterialPropertyVector.cc
r1196 r1315 25 25 // 26 26 // 27 // $Id: G4MaterialPropertyVector.cc,v 1.1 7 2009/04/21 15:35:45 gcosmoExp $28 // GEANT4 tag $Name: materials-V09-02-18$27 // $Id: G4MaterialPropertyVector.cc,v 1.18 2010/04/22 21:15:19 gum Exp $ 28 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 29 29 // 30 30 // … … 154 154 G4double G4MaterialPropertyVector::GetProperty(G4double aPhotonEnergy) const 155 155 { 156 G4MPVEntry *target, *temp;157 156 G4int left, right; 158 157 G4double ratio1, ratio2, pmright, pmleft, InterpolatedValue; … … 175 174 G4Exception("G4MaterialPropertyVector::GetProperty()", "OutOfRange", 176 175 JustWarning, "Attempt to retrieve property below range !"); 176 G4cout << " aPhotonEnergy = " << aPhotonEnergy/MeV 177 << " [MeV] PMmin = " << PMmin << " [MeV]" << G4endl; 177 178 return minProp; 178 179 } … … 182 183 G4Exception("G4MaterialPropertyVector::GetProperty()", "OutOfRange", 183 184 JustWarning, "Attempt to retrieve property above range !"); 185 G4cout << " aPhotonEnergy = " << aPhotonEnergy/MeV 186 << " [MeV] PMmax = " << PMmax << " [MeV]" << G4endl; 184 187 return maxProp; 185 188 } 186 187 target = new G4MPVEntry(aPhotonEnergy, 0.0); 188 189 temp = 0; 190 //temp = MPV.find(target); 191 std::vector<G4MPVEntry*>::const_iterator i; 192 for (i = MPV.begin(); i != MPV.end(); i++) 193 { 194 if (**i == *target) { temp = *i; break; } 195 } 196 if (temp != 0) 197 { 198 //////////////////////// 199 // Return actual value 200 //////////////////////// 201 202 G4double retval = temp->GetProperty(); 203 delete target; 204 return retval; 205 } 206 else 207 { 208 ////////////////////////////// 209 // Return interpolated value 210 ////////////////////////////// 211 212 GetAdjacentBins(aPhotonEnergy, &left, &right); 213 214 pmleft = MPV[left]->GetPhotonEnergy(); 215 pmright = MPV[right]->GetPhotonEnergy(); 216 ratio1 = (aPhotonEnergy-pmleft)/(pmright-pmleft); 217 ratio2 = 1 - ratio1; 218 InterpolatedValue = MPV[left]->GetProperty()*ratio2 + 219 MPV[right]->GetProperty()*ratio1; 220 delete target; 221 return InterpolatedValue; 222 } 189 190 ////////////////////////////// 191 // Return interpolated value 192 ////////////////////////////// 193 194 GetAdjacentBins(aPhotonEnergy, &left, &right); 195 pmleft = MPV[left]->GetPhotonEnergy(); 196 pmright = MPV[right]->GetPhotonEnergy(); 197 ratio1 = (aPhotonEnergy-pmleft)/(pmright-pmleft); 198 ratio2 = 1 - ratio1; 199 InterpolatedValue = MPV[left]->GetProperty()*ratio2 + 200 MPV[right]->GetProperty()*ratio1; 201 return InterpolatedValue; 223 202 } 224 203 … … 340 319 { 341 320 mid = (*left + *right)/2; 342 if (MPV[mid]->GetPhotonEnergy() < aPhotonEnergy)321 if (MPV[mid]->GetPhotonEnergy() <= aPhotonEnergy) 343 322 { 344 323 *left = mid;
Note: See TracChangeset
for help on using the changeset viewer.