Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4LinInterpolation Class Reference

#include <G4LinInterpolation.hh>

Inheritance diagram for G4LinInterpolation:
Collaboration diagram for G4LinInterpolation:

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
 
- Public Member Functions inherited from G4VDataSetAlgorithm
 G4VDataSetAlgorithm ()
 
virtual ~G4VDataSetAlgorithm ()
 

Detailed Description

Definition at line 52 of file G4LinInterpolation.hh.

Constructor & Destructor Documentation

G4LinInterpolation::G4LinInterpolation ( )

Definition at line 43 of file G4LinInterpolation.cc.

44 { }

Here is the caller graph for this function:

G4LinInterpolation::~G4LinInterpolation ( )

Definition at line 48 of file G4LinInterpolation.cc.

49 { }

Member Function Documentation

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.

58 {
59  //G4cout << "G4LinInterpolation is performed (2 arguments)" << G4endl;
60  G4int nBins = data.size() - 1;
61  G4double value = 0.;
62  if (x < points[0])
63  {
64  value = 0.;
65  }
66  else if (bin < nBins)
67  {
68  G4double e1 = points[bin];
69  G4double e2 = points[bin+1];
70  G4double d1 = data[bin];
71  G4double d2 = data[bin+1];
72  value = d1 + (d2 - d1)*(x - e1)/(e2 - e1);
73  }
74  else
75  {
76  value = data[nBins];
77  }
78  return value;
79 }
static const G4double d2
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
static const G4double d1
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

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.

90 {
91 //Linear Interpolation is performed on loagarithmic data set
92 //Equivalent to log-log interpolation on non-loagarithmic data set
93  //G4cout << "G4LinInterpolation is performed - (4 arguments)" << G4endl;
94  G4int nBins = data.size() - 1;
95  G4double value = 0.;
96  G4double log_x = std::log10(x);
97  if (x < points[0])
98  {
99  value = 0.;
100  }
101  else if (bin < nBins)
102  {
103  G4double log_e1 = log_points[bin];
104  G4double log_e2 = log_points[bin+1];
105  G4double log_d1 = log_data[bin];
106  G4double log_d2 = log_data[bin+1];
107 
108 // Values e1, e2, d1 and d2 are the log values of the corresponding
109 // original energy and data values. Simple linear interpolation performed
110 // on loagarithmic data should be equivalent to log-log interpolation
111  value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
112 
113 // Delogarithmize to obtain interpolated value
114  value = std::pow(10.,value);
115  }
116  else
117  {
118  value = data[nBins];
119  }
120  return value;
121 }
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
double G4double
Definition: G4Types.hh:76
G4VDataSetAlgorithm * G4LinInterpolation::Clone ( ) const
virtual

Implements G4VDataSetAlgorithm.

Definition at line 52 of file G4LinInterpolation.cc.

53 { return new G4LinInterpolation; }

Here is the call graph for this function:


The documentation for this class was generated from the following files: