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

#include <G4LogLogInterpolation.hh>

+ Inheritance diagram for G4LogLogInterpolation:

Public Member Functions

 G4LogLogInterpolation ()
 
 ~G4LogLogInterpolation ()
 
G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data) const override
 
G4double Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data, const G4DataVector &log_energies, const G4DataVector &log_data) const override
 
virtual G4VDataSetAlgorithmClone () const override
 
- 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
 
 G4VDataSetAlgorithm (const G4VDataSetAlgorithm &)=delete
 
G4VDataSetAlgorithmoperator= (const G4VDataSetAlgorithm &right)=delete
 

Detailed Description

Definition at line 51 of file G4LogLogInterpolation.hh.

Constructor & Destructor Documentation

◆ G4LogLogInterpolation()

G4LogLogInterpolation::G4LogLogInterpolation ( )
explicit

Definition at line 46 of file G4LogLogInterpolation.cc.

47{ }

Referenced by Clone().

◆ ~G4LogLogInterpolation()

G4LogLogInterpolation::~G4LogLogInterpolation ( )

Definition at line 51 of file G4LogLogInterpolation.cc.

52{ }

Member Function Documentation

◆ Calculate() [1/2]

G4double G4LogLogInterpolation::Calculate ( G4double  point,
G4int  bin,
const G4DataVector energies,
const G4DataVector data 
) const
overridevirtual

Implements G4VDataSetAlgorithm.

Definition at line 59 of file G4LogLogInterpolation.cc.

62{
63 G4int nBins = G4int(data.size() - 1);
64 G4double value = 0.;
65 if (x < points[0])
66 {
67 value = 0.;
68 }
69 else if (bin < nBins)
70 {
71 G4double e1 = points[bin];
72 G4double e2 = points[bin+1];
73 G4double d1 = data[bin];
74 G4double d2 = data[bin+1];
75 // Check of e1, e2, d1 and d2 values to avoid floating-point errors when estimating the
76 // interpolated value below
77 if ((d1 > 0.) && (d2 > 0.) && (e1 > 0.) && (e2 > 0.))
78 {
79
80 value = std::log10(d1)+(std::log10(d2/d1)/std::log10(e2/e1)*std::log10(x/e1));
81 value = std::pow(10.,value);
82 }
83 else value = 0.;
84 }
85 else
86 {
87 value = data[nBins];
88 }
89 return value;
90}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85

◆ Calculate() [2/2]

G4double G4LogLogInterpolation::Calculate ( G4double  point,
G4int  bin,
const G4DataVector energies,
const G4DataVector data,
const G4DataVector log_energies,
const G4DataVector log_data 
) const
overridevirtual

Implements G4VDataSetAlgorithm.

Definition at line 95 of file G4LogLogInterpolation.cc.

100{
101 G4int nBins = G4int(data.size() - 1);
102 G4double value = 0.;
103 G4double log_x = std::log10(x);
104 if (x < points[0])
105 {
106 value = 0.;
107 }
108 else if (bin < nBins)
109 {
110 G4double log_e1 = log_points[bin];
111 G4double log_e2 = log_points[bin+1];
112 G4double log_d1 = log_data[bin];
113 G4double log_d2 = log_data[bin+1];
114
115 // Values e1, e2, d1 and d2 are the log values of the corresponding
116 // original energy and data values. Simple linear interpolation performed
117 // on loagarithmic data should be equivalent to log-log interpolation
118 value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
119
120 // Delogarithmize to obtain interpolated value
121 value = std::pow(10.,value);
122 }
123 else
124 {
125 value = data[nBins];
126 }
127 return value;
128}

◆ Clone()

G4VDataSetAlgorithm * G4LogLogInterpolation::Clone ( ) const
overridevirtual

Implements G4VDataSetAlgorithm.

Definition at line 55 of file G4LogLogInterpolation.cc.


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