Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4LinLogInterpolation Class Reference

#include <G4LinLogInterpolation.hh>

Inheritance diagram for G4LinLogInterpolation:
G4VDataSetAlgorithm

Public Member Functions

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

Detailed Description

Definition at line 50 of file G4LinLogInterpolation.hh.

Constructor & Destructor Documentation

G4LinLogInterpolation::G4LinLogInterpolation ( )

Definition at line 40 of file G4LinLogInterpolation.cc.

Referenced by Clone().

41 { }
G4LinLogInterpolation::~G4LinLogInterpolation ( )

Definition at line 46 of file G4LinLogInterpolation.cc.

47 { }

Member Function Documentation

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

Implements G4VDataSetAlgorithm.

Definition at line 50 of file G4LinLogInterpolation.cc.

References plottest35::bin.

53 {
54  //G4cout << "G4LinLogInterpolation is performed on dataset (2 arguments) " << G4endl;
55  G4int nBins = data.size() - 1;
56  G4double value = 0.;
57  if (x < points[0])
58  {
59  value = 0.;
60  }
61  else if (bin < nBins)
62  {
63  G4double e1 = points[bin];
64  G4double e2 = points[bin+1];
65  G4double d1 = std::log(data[bin]);
66  G4double d2 = std::log(data[bin+1]);
67  value = std::exp(d1 + (d2 - d1)*(x - e1)/ (e2 - e1));
68  }
69  else
70  {
71  value = data[nBins];
72  }
73  return value;
74 }
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 G4LinLogInterpolation::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 76 of file G4LinLogInterpolation.cc.

References plottest35::bin.

81 {
82  //G4cout << "G4LinLogInterpolation is performed on dataset (4 arguments) " << G4endl;
83  G4int nBins = data.size() - 1;
84  G4double value = 0.;
85  //G4double log_x = std::log10(x);
86  if (x < points[0])
87  {
88  value = 0.;
89  }
90  else if (bin < nBins)
91  {
92  G4double e1 = points[bin];
93  G4double e2 = points[bin+1];
94  G4double d1 = data[bin];
95  G4double d2 = data[bin+1];
96  //G4double log_e1 = log_points[bin];
97  //G4double log_e2 = log_points[bin+1];
98  G4double log_d1 = log_data[bin];
99  G4double log_d2 = log_data[bin+1];
100  if (d1 > 0.0 && d2 > 0.0)
101  {
102 // Values e1, e2, d1 and d2 are the log values of the corresponding
103 // original energy and data values. Simple linear interpolation performed
104 // on loagarithmic data should be equivalent to log-log interpolation
105  //value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
106  value = std::exp(log_d1 + (log_d2 - log_d1)*(x - e1)/(e2 - e1));
107  }
108  else
109  {
110  if (d1 == 0.0) log_d1 = -300;
111  if (d2 == 0.0) log_d2 = -300;
112  value = std::exp(log_d1 + (log_d2 - log_d1)*(x - e1)/(e2 - e1));
113  }
114  }
115  else
116  {
117  value = data[nBins];
118  }
119  return value;
120 }
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
virtual G4VDataSetAlgorithm* G4LinLogInterpolation::Clone ( ) const
inlinevirtual

Implements G4VDataSetAlgorithm.

Definition at line 68 of file G4LinLogInterpolation.hh.

References G4LinLogInterpolation().


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