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

update processes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/lowenergy/src/G4LogLogInterpolation.cc

    r819 r961  
    2525//
    2626//
    27 // $Id: G4LogLogInterpolation.cc,v 1.7 2006/06/29 19:40:09 gunter Exp $
    28 // GEANT4 tag $Name: $
     27// $Id: G4LogLogInterpolation.cc,v 1.14 2008/12/12 08:50:59 sincerti Exp $
     28// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2929//
    3030// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
    31 //
     31//         Sebastian Incerti (incerti@cenbg.in2p3.fr)
     32//         Nicolas A. Karakatsanis (knicolas@mail.ntua.gr)
    3233// History:
    3334// -----------
    3435// 31 Jul 2001   MGP        Created
    35 //
     36// 27 Jun 2008   SI         Add check to avoid FPE errors
     37// 08 Dec 2008   NAK        Log-Log interpolation math formula streamlined, self-test function
    3638// -------------------------------------------------------------------
    3739
     
    5759{
    5860  G4int nBins = data.size() - 1;
     61//G4double oldresult = 0.;
    5962  G4double value = 0.;
    6063  if (x < points[0])
     
    6871      G4double d1 = data[bin];
    6972      G4double d2 = data[bin+1];
    70       value = (std::log10(d1)*std::log10(e2/x) + std::log10(d2)*std::log10(x/e1)) / std::log10(e2/e1);
    71       value = std::pow(10.,value);
     73// Check of e1, e2, d1 and d2 values to avoid floating-point errors when estimating the interpolated value below -- S.I., Jun. 2008
     74      if ((d1 > 0.) && (d2 > 0.) && (e1 > 0.) && (e2 > 0.))
     75        {
     76// Streamline the Log-Log Interpolation formula in order to reduce the required number of log10() function calls
     77// Variable oldresult contains the result of old implementation of Log-Log interpolation -- M.G.P. Jun. 2001
     78//       oldresult = (std::log10(d1)*std::log10(e2/x) + std::log10(d2)*std::log10(x/e1)) / std::log10(e2/e1);
     79//       oldresult = std::pow(10.,oldresult);
     80// Variable value contains the result of new implementation, after streamlining the math operation -- N.A.K. Oct. 2008
     81         value = std::log10(d1)+(std::log10(d2/d1)/std::log10(e2/e1)*std::log10(x/e1));
     82         value = std::pow(10.,value);
     83// Test of the new implementation result (value variable) against the old one (oldresult) -- N.A.K. Dec. 2008
     84//       G4double diffResult = value - oldresult;
     85//       G4double relativeDiff = 1e-11;
     86// Comparison of the two values based on a max allowable relative difference
     87//       if ( std::fabs(diffResult) > relativeDiff*std::fabs(oldresult) )
     88//        {
     89// Abort comparison when at least one of two results is infinite
     90//           if ((!std::isinf(oldresult)) && (!std::isinf(value)))
     91//            {
     92//              G4cout << "G4LogLogInterpolation> Old Interpolated Value is:" << oldresult << G4endl;
     93//              G4cout << "G4LogLogInterpolation> New Interpolated Value is:" << value << G4endl << G4endl;
     94//              G4cerr << "G4LogLogInterpolation> Error in Interpolation:" << G4endl;
     95//              G4cerr << "The difference between new and old interpolated value is:" << diffResult << G4endl << G4endl;
     96//            }
     97//        }
     98        }
     99      else value = 0.;
    72100    }
    73101  else
     
    75103      value = data[nBins];
    76104    }
    77 
    78105  return value;
    79106}
Note: See TracChangeset for help on using the changeset viewer.