Changeset 850 for trunk/source/materials/src/G4MaterialPropertyVector.cc
- Timestamp:
- Sep 10, 2008, 5:40:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/materials/src/G4MaterialPropertyVector.cc
r822 r850 25 25 // 26 26 // 27 // $Id: G4MaterialPropertyVector.cc,v 1.1 5 2006/06/29 19:12:56 gunterExp $28 // GEANT4 tag $Name: $27 // $Id: G4MaterialPropertyVector.cc,v 1.16 2008/06/05 23:38:51 gum Exp $ 28 // GEANT4 tag $Name: HEAD $ 29 29 // 30 30 // … … 98 98 ///////////////// 99 99 100 G4MaterialPropertyVector::G4MaterialPropertyVector(G4double *Photon Momenta,100 G4MaterialPropertyVector::G4MaterialPropertyVector(G4double *PhotonEnergies, 101 101 G4double *PropertyValues, 102 102 G4int NumElements) … … 106 106 107 107 // create a vector filling it with the values 108 // from Photon Momenta[] and PropertyValues[]108 // from PhotonEnergies[] and PropertyValues[] 109 109 110 110 for(G4int i = 0; i < NumElements; i++) { 111 AddElement(Photon Momenta[i], PropertyValues[i]);111 AddElement(PhotonEnergies[i], PropertyValues[i]); 112 112 } 113 113 } … … 141 141 // Methods 142 142 //////////// 143 void G4MaterialPropertyVector::AddElement(G4double aPhoton Momentum,143 void G4MaterialPropertyVector::AddElement(G4double aPhotonEnergy, 144 144 G4double aPropertyValue) 145 145 { 146 146 G4MPVEntry *newElement; 147 147 148 newElement = new G4MPVEntry(aPhoton Momentum, aPropertyValue);148 newElement = new G4MPVEntry(aPhotonEnergy, aPropertyValue); 149 149 MPV.push_back(newElement); 150 150 std::sort(MPV.begin(), MPV.end(), MPVEntry_less()); … … 152 152 } 153 153 154 void G4MaterialPropertyVector::RemoveElement(G4double aPhoton Momentum)154 void G4MaterialPropertyVector::RemoveElement(G4double aPhotonEnergy) 155 155 { 156 156 G4MPVEntry *newElement; 157 157 G4MPVEntry *success=0; 158 158 159 newElement = new G4MPVEntry(aPhoton Momentum, DBL_MAX);159 newElement = new G4MPVEntry(aPhotonEnergy, DBL_MAX); 160 160 161 161 std::vector<G4MPVEntry*>::iterator i; … … 179 179 180 180 G4double 181 G4MaterialPropertyVector::GetProperty(G4double aPhoton Momentum) const181 G4MaterialPropertyVector::GetProperty(G4double aPhotonEnergy) const 182 182 { 183 183 G4MPVEntry *target, *temp; … … 189 189 ///////////////////////// 190 190 191 G4double PMmin = MPV.front()->GetPhoton Momentum();191 G4double PMmin = MPV.front()->GetPhotonEnergy(); 192 192 G4double minProp = MPV.front()->GetProperty(); 193 G4double PMmax = MPV.back() ->GetPhoton Momentum();193 G4double PMmax = MPV.back() ->GetPhotonEnergy(); 194 194 G4double maxProp = MPV.back() ->GetProperty(); 195 195 … … 198 198 /////////////////////////////////////////// 199 199 200 if (aPhoton Momentum< PMmin)200 if (aPhotonEnergy < PMmin) 201 201 { 202 202 G4cout << "\nWarning: G4MaterialPropertyVector::GetProperty"; … … 206 206 } 207 207 208 if (aPhoton Momentum> PMmax)208 if (aPhotonEnergy > PMmax) 209 209 { 210 210 G4cout << "\nWarning: G4MaterialPropertyVector::GetProperty"; … … 214 214 } 215 215 216 target = new G4MPVEntry(aPhoton Momentum, 0.0);216 target = new G4MPVEntry(aPhotonEnergy, 0.0); 217 217 218 218 temp = 0; … … 236 236 ////////////////////////////// 237 237 238 GetAdjacentBins(aPhoton Momentum, &left, &right);239 240 pmleft = MPV[left]->GetPhoton Momentum();241 pmright = MPV[right]->GetPhoton Momentum();242 ratio1 = (aPhoton Momentum-pmleft)/(pmright-pmleft);238 GetAdjacentBins(aPhotonEnergy, &left, &right); 239 240 pmleft = MPV[left]->GetPhotonEnergy(); 241 pmright = MPV[right]->GetPhotonEnergy(); 242 ratio1 = (aPhotonEnergy-pmleft)/(pmright-pmleft); 243 243 ratio2 = 1 - ratio1; 244 244 InterpolatedValue = MPV[left]->GetProperty()*ratio2 + … … 264 264 } 265 265 266 G4double G4MaterialPropertyVector::GetPhoton Momentum() const266 G4double G4MaterialPropertyVector::GetPhotonEnergy() const 267 267 { 268 268 // For use with G4MaterialPropertyVector iterator 269 269 270 270 if(CurrentEntry == -1 || CurrentEntry >= NumEntries) { 271 G4Exception("G4MaterialPropertyVector::GetPhoton Momentum==>"272 "Iterator attempted to Retrieve Photon Momentumout of range");271 G4Exception("G4MaterialPropertyVector::GetPhotonEnergy ==>" 272 "Iterator attempted to Retrieve Photon Energy out of range"); 273 273 return DBL_MAX; 274 274 } 275 275 else { 276 return MPV[CurrentEntry]->GetPhoton Momentum();276 return MPV[CurrentEntry]->GetPhotonEnergy(); 277 277 } 278 278 } 279 279 280 280 G4double 281 G4MaterialPropertyVector::GetPhoton Momentum(G4double aProperty) const281 G4MaterialPropertyVector::GetPhotonEnergy(G4double aProperty) const 282 282 { 283 283 // ***NB*** 284 // Assumes that the property is an increasing function of photon momentum(e.g.284 // Assumes that the property is an increasing function of photon energy (e.g. 285 285 // refraction index) 286 286 // ***NB*** 287 287 // 288 // Returns the photon momentumcorresponding to the property value passed in.289 // If several photon momentumvalues correspond to the value passed in, the290 // function returns the first photon momentumin the vector that corresponds288 // Returns the photon energy corresponding to the property value passed in. 289 // If several photon energy values correspond to the value passed in, the 290 // function returns the first photon energy in the vector that corresponds 291 291 // to that value. 292 292 … … 299 299 300 300 G4double PropMin = MPV.front()->GetProperty(); 301 G4double PMmin = MPV.front()->GetPhoton Momentum();301 G4double PMmin = MPV.front()->GetPhotonEnergy(); 302 302 G4double PropMax = MPV.back() ->GetProperty(); 303 G4double PMmax = MPV.back() ->GetPhoton Momentum();303 G4double PMmax = MPV.back() ->GetPhotonEnergy(); 304 304 305 305 /////////////////////////////////////////// … … 309 309 if (aProperty < PropMin) 310 310 { 311 G4cout << "\nWarning: G4MaterialPropertyVector::GetPhoton Momentum";312 G4cout << "\n==> attempt to Retrieve Photon Momentumout of range"311 G4cout << "\nWarning: G4MaterialPropertyVector::GetPhotonEnergy"; 312 G4cout << "\n==> attempt to Retrieve Photon Energy out of range" 313 313 << G4endl; 314 314 return PMmin; … … 316 316 317 317 if (aProperty > PropMax) { 318 G4cout << "\nWarning: G4MaterialPropertyVector::GetPhoton Momentum";319 G4cout << "\n==> attempt to Retrieve Photon Momentumout of range"318 G4cout << "\nWarning: G4MaterialPropertyVector::GetPhotonEnergy"; 319 G4cout << "\n==> attempt to Retrieve Photon Energy out of range" 320 320 << G4endl; 321 321 return PMmax; … … 335 335 if (MPV[mid]->GetProperty() == aProperty) { 336 336 337 // Get first photon momentumvalue in vector that337 // Get first photon energy value in vector that 338 338 // corresponds to property value 339 339 … … 343 343 } 344 344 345 InterpolatedValue = MPV[mid]->GetPhoton Momentum();346 goto end_GetPhoton Momentum;345 InterpolatedValue = MPV[mid]->GetPhotonEnergy(); 346 goto end_GetPhotonEnergy; 347 347 } 348 348 if (MPV[mid]->GetProperty() < aProperty) … … 357 357 ratio1 = (aProperty - pleft) / (pright - pleft); 358 358 ratio2 = 1 - ratio1; 359 InterpolatedValue = MPV[left]->GetPhoton Momentum()*ratio2 +360 MPV[right]->GetPhoton Momentum()*ratio1;361 362 end_GetPhoton Momentum:359 InterpolatedValue = MPV[left]->GetPhotonEnergy()*ratio2 + 360 MPV[right]->GetPhotonEnergy()*ratio1; 361 362 end_GetPhotonEnergy: 363 363 364 364 return InterpolatedValue; … … 392 392 393 393 void 394 G4MaterialPropertyVector::GetAdjacentBins(G4double aPhoton Momentum,394 G4MaterialPropertyVector::GetAdjacentBins(G4double aPhotonEnergy, 395 395 G4int *left, 396 396 G4int *right) const … … 401 401 *right = (MPV.size() - 1); // was .entries() 402 402 403 // find values in bins on either side of aPhoton Momentum403 // find values in bins on either side of aPhotonEnergy 404 404 405 405 do { 406 406 mid = (*left + *right)/2; 407 407 408 if (MPV[mid]->GetPhoton Momentum() < aPhotonMomentum)408 if (MPV[mid]->GetPhotonEnergy() < aPhotonEnergy) 409 409 { 410 410 *left = mid;
Note: See TracChangeset
for help on using the changeset viewer.