Ignore:
Timestamp:
Nov 19, 2009, 2:53:25 PM (15 years ago)
Author:
garnier
Message:

update par rapport a CVS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/lowenergy/src/G4LinLogLogInterpolation.cc

    r819 r1192  
    5353                                          const G4DataVector& data) const
    5454{
     55  //G4cout << "G4LinLogLogInterpolation is performed (2 arguments) " << G4endl;
    5556  G4int nBins = data.size() - 1;
    5657  G4double value = 0.;
     
    7980  return value;
    8081}
     82
     83G4double G4LinLogLogInterpolation::Calculate(G4double x, G4int bin,
     84                                          const G4DataVector& points,
     85                                          const G4DataVector& data,
     86                                          const G4DataVector& log_points,
     87                                          const G4DataVector& log_data) const
     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}
Note: See TracChangeset for help on using the changeset viewer.