- Timestamp:
- Nov 19, 2009, 2:53:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/lowenergy/src/G4LinLogInterpolation.cc
r819 r1192 52 52 const G4DataVector& data) const 53 53 { 54 //G4cout << "G4LinLogInterpolation is performed on dataset (2 arguments) " << G4endl; 54 55 G4int nBins = data.size() - 1; 55 56 G4double value = 0.; … … 72 73 return value; 73 74 } 75 76 G4double G4LinLogInterpolation::Calculate(G4double x, G4int bin, 77 const G4DataVector& points, 78 const G4DataVector& data, 79 const G4DataVector& /*log_points*/, 80 const G4DataVector& log_data) const 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 } 121
Note: See TracChangeset
for help on using the changeset viewer.