Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LinLogLogInterpolation Class Reference

#include <G4LinLogLogInterpolation.hh>

Inheritance diagram for G4LinLogLogInterpolation:
Collaboration diagram for G4LinLogLogInterpolation:

Public Member Functions

 G4LinLogLogInterpolation ()
 
 ~G4LinLogLogInterpolation ()
 
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 49 of file G4LinLogLogInterpolation.hh.

Constructor & Destructor Documentation

G4LinLogLogInterpolation::G4LinLogLogInterpolation ( )

Definition at line 39 of file G4LinLogLogInterpolation.cc.

40 { }

Here is the caller graph for this function:

G4LinLogLogInterpolation::~G4LinLogLogInterpolation ( )

Definition at line 44 of file G4LinLogLogInterpolation.cc.

45 { }

Member Function Documentation

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

Implements G4VDataSetAlgorithm.

Definition at line 51 of file G4LinLogLogInterpolation.cc.

54 {
55  //G4cout << "G4LinLogLogInterpolation is performed (2 arguments) " << G4endl;
56  G4int nBins = data.size() - 1;
57  G4double value = 0.;
58  if (x < points[0])
59  {
60  value = 0.;
61  }
62  else if (bin < nBins)
63  {
64  G4double e1 = points[bin];
65  G4double e2 = points[bin+1];
66  G4double d1 = data[bin];
67  G4double d2 = data[bin+1];
68  if(d1 > 0.0 && d2 > 0.0) {
69  value = (std::log10(d1)*std::log10(e2/x) + std::log10(d2)*std::log10(x/e1)) / std::log10(e2/e1);
70  value = std::pow(10.,value);
71  } else {
72  value = (d1*std::log10(e2/x) + d2*std::log10(x/e1)) / std::log10(e2/e1);
73  }
74  }
75  else
76  {
77  value = data[nBins];
78  }
79 
80  return value;
81 }
tuple bin
Definition: plottest35.py:22
static const G4double d2
tuple x
Definition: test.py:50
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
G4double G4LinLogLogInterpolation::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 83 of file G4LinLogLogInterpolation.cc.

88 {
89  //G4cout << "G4LinLogLogInterpolation is performed(4 arguments) " << G4endl;
90  G4int nBins = data.size() - 1;
91  G4double value = 0.;
92  G4double log_x = std::log10(x);
93  if (x < points[0])
94  {
95  value = 0.;
96  }
97  else if (bin < nBins)
98  {
99  G4double e1 = points[bin];
100  G4double e2 = points[bin+1];
101  G4double d1 = data[bin];
102  G4double d2 = data[bin+1];
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  //G4cout << "x = " << x << " , log_x = " << log_x << " , bin = " << bin << G4endl;
108  //G4cout << "e1 = " << e1 << " , d1 = " << d1 << G4endl;
109  //G4cout << "e2 = " << e2 << " , d2 = " << d2 << G4endl;
110  //G4cout << "log_e1 = " << log_e1 << " , log_d1 = " << log_d1 << G4endl;
111  //G4cout << "log_e2 = " << log_e2 << " , log_d2 = " << log_d2 <<G4endl;
112  if (d1 > 0.0 && d2 > 0.0)
113  {
114  // Values e1, e2, d1 and d2 are the log values of the corresponding
115  // original energy and data values. Simple linear interpolation performed
116  // on loagarithmic data should be equivalent to log-log interpolation
117  value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1);
118 
119  //G4cout << "Case of normal log-log interpolation" << G4endl;
120  //G4cout << "Temp log interpolated value: log_value = " << value << G4endl;
121 
122  // Delogarithmize to obtain interpolated value
123  value = std::pow(10.,value);
124 
125  //G4cout << "Final Interpolated value: " << value << G4endl << G4endl;
126  }
127  else
128  {
129  // Case of semi log-log interpolation
130  //G4cout << "G4LinLogLogInterpolation - Case of SemiLogInterpolation" << G4endl;
131  if (e1 == 0.0) e1 = 1e-300;
132  if (e2 == 0.0) e2 = 1e-300;
133  value = d1 + (d2 - d1)*(log_x - log_e1)/(log_e2 - log_e1);
134  //G4cout << "LinLogInterpolation: Final Interpolated value: " << value << G4endl << G4endl;
135  }
136  }
137  else
138  {
139  value = data[nBins];
140  }
141  return value;
142 }
tuple bin
Definition: plottest35.py:22
static const G4double d2
tuple x
Definition: test.py:50
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
G4VDataSetAlgorithm * G4LinLogLogInterpolation::Clone ( ) const
virtual

Implements G4VDataSetAlgorithm.

Definition at line 47 of file G4LinLogLogInterpolation.cc.

Here is the call graph for this function:


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