G4LinLogLogInterpolation Class Reference

#include <G4LinLogLogInterpolation.hh>

Inheritance diagram for G4LinLogLogInterpolation:

G4VDataSetAlgorithm

Public Member Functions

 G4LinLogLogInterpolation ()
 ~G4LinLogLogInterpolation ()
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
virtual G4VDataSetAlgorithmClone () const

Detailed Description

Definition at line 49 of file G4LinLogLogInterpolation.hh.


Constructor & Destructor Documentation

G4LinLogLogInterpolation::G4LinLogLogInterpolation (  ) 

Definition at line 39 of file G4LinLogLogInterpolation.cc.

00040 { }

G4LinLogLogInterpolation::~G4LinLogLogInterpolation (  ) 

Definition at line 44 of file G4LinLogLogInterpolation.cc.

00045 { }


Member Function Documentation

G4double G4LinLogLogInterpolation::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 83 of file G4LinLogLogInterpolation.cc.

00088 {
00089   //G4cout << "G4LinLogLogInterpolation is performed(4 arguments)  " << G4endl;
00090   G4int nBins = data.size() - 1;
00091   G4double value = 0.;
00092   G4double log_x = std::log10(x);
00093   if (x < points[0])
00094     {
00095       value = 0.;
00096     }
00097   else if (bin < nBins)
00098     {
00099       G4double e1 = points[bin];
00100       G4double e2 = points[bin+1];
00101       G4double d1 = data[bin];
00102       G4double d2 = data[bin+1];      
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       //G4cout << "x = " << x << " , log_x = " << log_x << " , bin = " << bin << G4endl;
00108       //G4cout << "e1 = " << e1 << " , d1 = " << d1 << G4endl;
00109       //G4cout << "e2 = " << e2 << " , d2 = " << d2 << G4endl;
00110       //G4cout << "log_e1 = " << log_e1 << " , log_d1 = " << log_d1 << G4endl;
00111       //G4cout << "log_e2 = " << log_e2 << " , log_d2 = " << log_d2 <<G4endl;
00112       if (d1 > 0.0 && d2 > 0.0)
00113        {
00114          // Values e1, e2, d1 and d2 are the log values of the corresponding
00115          // original energy and data values. Simple linear interpolation performed
00116          // on loagarithmic data should be equivalent to log-log interpolation
00117          value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
00118 
00119          //G4cout << "Case of normal log-log interpolation" << G4endl;
00120          //G4cout << "Temp log interpolated value: log_value = " << value << G4endl;
00121 
00122          // Delogarithmize to obtain interpolated value
00123          value = std::pow(10.,value);
00124 
00125          //G4cout << "Final Interpolated value: " << value << G4endl << G4endl;
00126        }
00127      else
00128        {
00129         // Case of semi log-log interpolation
00130         //G4cout << "G4LinLogLogInterpolation - Case of SemiLogInterpolation" << G4endl;
00131         if (e1 == 0.0) e1 = 1e-300;
00132         if (e2 == 0.0) e2 = 1e-300;
00133         value = d1 + (d2 - d1)*(log_x - log_e1)/(log_e2 - log_e1);
00134         //G4cout << "LinLogInterpolation: Final Interpolated value: " << value << G4endl << G4endl;
00135        }
00136     }
00137   else
00138     {
00139       value = data[nBins];
00140     }
00141   return value;
00142 }

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

Implements G4VDataSetAlgorithm.

Definition at line 51 of file G4LinLogLogInterpolation.cc.

00054 {
00055   //G4cout << "G4LinLogLogInterpolation is performed (2 arguments) " << G4endl;
00056   G4int nBins = data.size() - 1;
00057   G4double value = 0.;
00058   if (x < points[0])
00059     {
00060       value = 0.;
00061     }
00062   else if (bin < nBins)
00063     {
00064       G4double e1 = points[bin];
00065       G4double e2 = points[bin+1];
00066       G4double d1 = data[bin];
00067       G4double d2 = data[bin+1];
00068       if(d1 > 0.0 && d2 > 0.0) {
00069         value = (std::log10(d1)*std::log10(e2/x) + std::log10(d2)*std::log10(x/e1)) / std::log10(e2/e1);
00070         value = std::pow(10.,value);
00071       } else {
00072         value = (d1*std::log10(e2/x) + d2*std::log10(x/e1)) / std::log10(e2/e1);
00073       }
00074     }
00075   else
00076     {
00077       value = data[nBins];
00078     }
00079 
00080   return value;
00081 }

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

Implements G4VDataSetAlgorithm.

Definition at line 47 of file G4LinLogLogInterpolation.cc.

00048 { return new G4LinLogLogInterpolation; }


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