G4LinInterpolation Class Reference

#include <G4LinInterpolation.hh>

Inheritance diagram for G4LinInterpolation:

G4VDataSetAlgorithm

Public Member Functions

 G4LinInterpolation ()
 ~G4LinInterpolation ()
G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data) const
G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data, const G4DataVector &log_energies, const G4DataVector &log_data) const
G4VDataSetAlgorithmClone () const

Detailed Description

Definition at line 52 of file G4LinInterpolation.hh.


Constructor & Destructor Documentation

G4LinInterpolation::G4LinInterpolation (  ) 

Definition at line 43 of file G4LinInterpolation.cc.

00044 { }

G4LinInterpolation::~G4LinInterpolation (  ) 

Definition at line 48 of file G4LinInterpolation.cc.

00049 { }


Member Function Documentation

G4double G4LinInterpolation::Calculate ( G4double  point,
G4int  bin,
const G4DataVector energies,
const G4DataVector data,
const G4DataVector log_energies,
const G4DataVector log_data 
) const [virtual]

Implements G4VDataSetAlgorithm.

Definition at line 85 of file G4LinInterpolation.cc.

00090 {
00091 //Linear Interpolation is performed on loagarithmic data set
00092 //Equivalent to log-log interpolation on non-loagarithmic data set
00093   //G4cout << "G4LinInterpolation is performed - (4 arguments)" << G4endl;
00094   G4int nBins = data.size() - 1;
00095   G4double value = 0.;
00096   G4double log_x = std::log10(x);
00097   if (x < points[0])
00098     {
00099       value = 0.;
00100     }
00101   else if (bin < nBins)
00102     {
00103       G4double log_e1 = log_points[bin];
00104       G4double log_e2 = log_points[bin+1];
00105       G4double log_d1 = log_data[bin];
00106       G4double log_d2 = log_data[bin+1];
00107 
00108 // Values e1, e2, d1 and d2 are the log values of the corresponding
00109 // original energy and data values. Simple linear interpolation performed
00110 // on loagarithmic data should be equivalent to log-log interpolation
00111       value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
00112 
00113 // Delogarithmize to obtain interpolated value
00114       value = std::pow(10.,value);
00115    }
00116  else
00117    {
00118      value = data[nBins];
00119    }
00120   return value;
00121 }

G4double G4LinInterpolation::Calculate ( G4double  point,
G4int  bin,
const G4DataVector energies,
const G4DataVector data 
) const [virtual]

Implements G4VDataSetAlgorithm.

Definition at line 55 of file G4LinInterpolation.cc.

Referenced by G4EMDataSet::RandomSelect(), and G4DataSet::RandomSelect().

00058 {
00059   //G4cout << "G4LinInterpolation is performed (2 arguments)" << G4endl;
00060   G4int nBins = data.size() - 1;
00061   G4double value = 0.;
00062   if (x < points[0])
00063     {
00064       value = 0.;
00065     }
00066   else if (bin < nBins)
00067     {
00068       G4double e1 = points[bin];
00069       G4double e2 = points[bin+1];
00070       G4double d1 = data[bin];
00071       G4double d2 = data[bin+1];
00072       value = d1 + (d2 - d1)*(x - e1)/(e2 - e1);
00073     }
00074   else
00075     {
00076       value = data[nBins];
00077     }
00078   return value;
00079 }

G4VDataSetAlgorithm * G4LinInterpolation::Clone (  )  const [virtual]

Implements G4VDataSetAlgorithm.

Definition at line 52 of file G4LinInterpolation.cc.

00053 { return new G4LinInterpolation; }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:25 2013 for Geant4 by  doxygen 1.4.7