Ignore:
Timestamp:
Apr 6, 2009, 12:30:29 PM (15 years ago)
Author:
garnier
Message:

update processes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPVector.cc

    r819 r962  
    2929//
    3030// 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi)
     31// 080808 bug fix in Sample() and GetXsec() by T. Koi
    3132//
    3233#include "G4NeutronHPVector.hh"
     
    170171      //if( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001)
    171172      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 ) )
    173176      {
    174177        y = theData[low].GetY();
     
    366369      do
    367370      {
     371//080808
     372/*
     373        G4double rand;
    368374        G4double value, test, baseline;
    369375        baseline = theData[GetVectorLength()-1].GetX()-theData[0].GetX();
    370         G4double rand;
    371376        do
    372377        {
     
    379384        while( test < rand && test > 0 );
    380385        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
    381423      }
    382424      while(IsBlocked(result));
Note: See TracChangeset for help on using the changeset viewer.