Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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
 
- 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.

Referenced by Clone().

44 { }
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.

References plottest35::bin.

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

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 }
tuple bin
Definition: plottest35.py:22
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
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.

References plottest35::bin.

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 }
tuple bin
Definition: plottest35.py:22
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
G4VDataSetAlgorithm * G4LinInterpolation::Clone ( ) const
virtual

Implements G4VDataSetAlgorithm.

Definition at line 52 of file G4LinInterpolation.cc.

References G4LinInterpolation().

53 { return new G4LinInterpolation; }

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