- Timestamp:
- Nov 19, 2009, 2:53:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/lowenergy/src/G4LogLogInterpolation.cc
r1007 r1192 25 25 // 26 26 // 27 // $Id: G4LogLogInterpolation.cc,v 1.1 4 2008/12/12 08:50:59sincerti Exp $28 // GEANT4 tag $Name: geant4-09-02$27 // $Id: G4LogLogInterpolation.cc,v 1.16 2009/09/25 07:41:34 sincerti Exp $ 28 // GEANT4 tag $Name: emlowen-V09-02-64 $ 29 29 // 30 30 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch) … … 36 36 // 27 Jun 2008 SI Add check to avoid FPE errors 37 37 // 08 Dec 2008 NAK Log-Log interpolation math formula streamlined, self-test function 38 // 14 Jun 2008 NAK New implementation for log-log interpolation after directly loading 39 // logarithmic values from G4EMLOW dataset 38 40 // ------------------------------------------------------------------- 39 41 … … 58 60 const G4DataVector& data) const 59 61 { 62 //G4cout << "G4LogLogInterpolation is performed (2 arguments) " << G4endl; 60 63 G4int nBins = data.size() - 1; 61 64 //G4double oldresult = 0.; … … 105 108 return value; 106 109 } 110 111 112 // Nicolas A. Karakatsanis: New implementation of log-log interpolation after directly loading 113 // logarithmic values from G4EMLOW dataset 114 115 G4double G4LogLogInterpolation::Calculate(G4double x, G4int bin, 116 const G4DataVector& points, 117 const G4DataVector& data, 118 const G4DataVector& log_points, 119 const G4DataVector& log_data) const 120 { 121 //G4cout << "G4LogLogInterpolation is performed (4 arguments) " << G4endl; 122 G4int nBins = data.size() - 1; 123 G4double value = 0.; 124 G4double log_x = std::log10(x); 125 if (x < points[0]) 126 { 127 value = 0.; 128 } 129 else if (bin < nBins) 130 { 131 G4double log_e1 = log_points[bin]; 132 G4double log_e2 = log_points[bin+1]; 133 G4double log_d1 = log_data[bin]; 134 G4double log_d2 = log_data[bin+1]; 135 136 //G4cout << "x = " << x << " , logx = " << log_x << " , bin = " << bin << G4endl; 137 //G4cout << "e1 = " << points[bin] << " d1 = " << data[bin] << G4endl; 138 //G4cout << "e2 = " << points[bin+1] << " d2 = " << data[bin+1] << G4endl; 139 //G4cout << "loge1 = " << log_e1 << " logd1 = " << log_d1 << G4endl; 140 //G4cout << "loge2 = " << log_e2 << " logd2 = " << log_d2 << G4endl; 141 142 // Values e1, e2, d1 and d2 are the log values of the corresponding 143 // original energy and data values. Simple linear interpolation performed 144 // on loagarithmic data should be equivalent to log-log interpolation 145 value = log_d1 + (log_d2 - log_d1)*(log_x - log_e1)/(log_e2 - log_e1); 146 147 // Delogarithmize to obtain interpolated value 148 value = std::pow(10.,value); 149 } 150 else 151 { 152 value = data[nBins]; 153 } 154 return value; 155 }
Note: See TracChangeset
for help on using the changeset viewer.