- Timestamp:
- Apr 6, 2009, 12:30:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPVector.cc
r819 r962 29 29 // 30 30 // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi) 31 // 080808 bug fix in Sample() and GetXsec() by T. Koi 31 32 // 32 33 #include "G4NeutronHPVector.hh" … … 170 171 //if( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 171 172 if ( theData[high].GetX() !=0 172 &&( theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 173 //080808 TKDB 174 //&&( theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 175 &&( std::abs( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() ) < 0.000001 ) ) 173 176 { 174 177 y = theData[low].GetY(); … … 366 369 do 367 370 { 371 //080808 372 /* 373 G4double rand; 368 374 G4double value, test, baseline; 369 375 baseline = theData[GetVectorLength()-1].GetX()-theData[0].GetX(); 370 G4double rand;371 376 do 372 377 { … … 379 384 while( test < rand && test > 0 ); 380 385 result = value; 386 */ 387 G4double rand; 388 G4double value, test; 389 do 390 { 391 rand = G4UniformRand(); 392 G4int ibin = -1; 393 for ( G4int i = 0 ; i < GetVectorLength() ; i++ ) 394 { 395 if ( rand < theIntegral[i] ) 396 { 397 ibin = i; 398 break; 399 } 400 } 401 if ( ibin < 0 ) G4cout << "TKDB 080807 " << rand << G4endl; 402 // result 403 rand = G4UniformRand(); 404 G4double x1, x2; 405 if ( ibin == 0 ) 406 { 407 x1 = theData[ ibin ].GetX(); 408 value = x1; 409 break; 410 } 411 else 412 { 413 x1 = theData[ ibin-1 ].GetX(); 414 } 415 416 x2 = theData[ ibin ].GetX(); 417 value = rand * ( x2 - x1 ) + x1; 418 test = GetY ( value ) / std::max ( GetY( ibin-1 ) , GetY ( ibin ) ); 419 } 420 while ( G4UniformRand() > test ); 421 result = value; 422 //080807 381 423 } 382 424 while(IsBlocked(result));
Note: See TracChangeset
for help on using the changeset viewer.