Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LinInterpolation Class Reference

#include <G4LinInterpolation.hh>

+ Inheritance 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 ()
 
virtual G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data) const =0
 
virtual G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data, const G4DataVector &log_energies, const G4DataVector &log_data) const =0
 
virtual G4VDataSetAlgorithmClone () const =0
 

Detailed Description

Definition at line 51 of file G4LinInterpolation.hh.

Constructor & Destructor Documentation

◆ G4LinInterpolation()

G4LinInterpolation::G4LinInterpolation ( )

Definition at line 42 of file G4LinInterpolation.cc.

43{ }

Referenced by Clone().

◆ ~G4LinInterpolation()

G4LinInterpolation::~G4LinInterpolation ( )

Definition at line 47 of file G4LinInterpolation.cc.

48{ }

Member Function Documentation

◆ Calculate() [1/2]

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

Implements G4VDataSetAlgorithm.

Definition at line 54 of file G4LinInterpolation.cc.

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

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

◆ Calculate() [2/2]

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 84 of file G4LinInterpolation.cc.

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

◆ Clone()

G4VDataSetAlgorithm * G4LinInterpolation::Clone ( ) const
virtual

Implements G4VDataSetAlgorithm.

Definition at line 51 of file G4LinInterpolation.cc.


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