Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: G4SemiLogInterpolation.cc,v 1.4 2002/05/28 09:20:21 pia Exp $ >> 25 // GEANT4 tag $Name: geant4-05-02-patch-01 $ 27 // 26 // 28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@ 27 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch) 29 // 28 // 30 // History: 29 // History: 31 // ----------- 30 // ----------- 32 // 31 Jul 2001 MGP Created 31 // 31 Jul 2001 MGP Created 33 // 32 // 34 // ------------------------------------------- 33 // ------------------------------------------------------------------- 35 34 36 #include "G4SemiLogInterpolation.hh" 35 #include "G4SemiLogInterpolation.hh" 37 36 38 //....oooOO0OOooo........oooOO0OOooo........oo << 39 // Constructor 37 // Constructor >> 38 40 G4SemiLogInterpolation::G4SemiLogInterpolation 39 G4SemiLogInterpolation::G4SemiLogInterpolation() 41 { } 40 { } 42 41 43 42 44 //....oooOO0OOooo........oooOO0OOooo........oo << 45 // Destructor 43 // Destructor >> 44 46 G4SemiLogInterpolation::~G4SemiLogInterpolatio 45 G4SemiLogInterpolation::~G4SemiLogInterpolation() 47 { } 46 { } 48 47 49 //....oooOO0OOooo........oooOO0OOooo........oo << 50 G4VDataSetAlgorithm* G4SemiLogInterpolation::C 48 G4VDataSetAlgorithm* G4SemiLogInterpolation::Clone() const 51 { return new G4SemiLogInterpolation; } 49 { return new G4SemiLogInterpolation; } 52 50 53 //....oooOO0OOooo........oooOO0OOooo........oo << 51 54 G4double G4SemiLogInterpolation::Calculate(G4d 52 G4double G4SemiLogInterpolation::Calculate(G4double x, G4int bin, 55 const G4DataVector& points, 53 const G4DataVector& points, 56 const G4DataVector& data) const 54 const G4DataVector& data) const 57 { 55 { 58 G4int nBins = G4int(data.size() - 1); << 56 G4int nBins = data.size() - 1; 59 G4double value = 0.; 57 G4double value = 0.; 60 if (x < points[0]) 58 if (x < points[0]) 61 { 59 { 62 value = 0.; 60 value = 0.; 63 } 61 } 64 else if (bin < nBins) 62 else if (bin < nBins) 65 { 63 { 66 G4double e1 = points[bin]; 64 G4double e1 = points[bin]; 67 G4double e2 = points[bin+1]; 65 G4double e2 = points[bin+1]; 68 G4double d1 = data[bin]; 66 G4double d1 = data[bin]; 69 G4double d2 = data[bin+1]; 67 G4double d2 = data[bin+1]; 70 value = (d1*std::log10(e2/x) + d2*std::l << 68 value = (d1*log10(e2/x) + d2*log10(x/e1)) / log10(e2/e1); 71 } 69 } 72 else 70 else 73 { 71 { 74 value = data[nBins]; 72 value = data[nBins]; 75 } 73 } 76 return value; 74 return value; 77 } 75 } 78 << 79 //....oooOO0OOooo........oooOO0OOooo........oo << 80 G4double G4SemiLogInterpolation::Calculate(G4d << 81 const G4DataVector& points, << 82 con << 83 con << 84 const G4DataVector& /*log_d << 85 { << 86 //A combination of logarithmic interpolation << 87 //linear Interpolation on data set << 88 //G4cout << "G4SemiLogInterpolation is perfo << 89 G4int nBins = G4int(data.size() - 1); << 90 G4double value = 0.; << 91 G4double log_x = std::log10(x); << 92 if (x < points[0]) << 93 { << 94 value = 0.; << 95 } << 96 else if (bin < nBins) << 97 { << 98 G4double e1 = points[bin]; << 99 G4double e2 = points[bin+1]; << 100 G4double d1 = data[bin]; << 101 G4double d2 = data[bin+1]; << 102 G4double log_e1 = log_points[bin]; << 103 G4double log_e2 = log_points[bin+1]; << 104 << 105 // Values log_e1 and log_e2 are the log << 106 // original energy actual values. Origin << 107 // Simple linear interpolation performed << 108 // should be equivalent to semi log-log << 109 if (e1 == 0.0) log_e1 = -300; << 110 if (e2 == 0.0) log_e2 = -300; << 111 value = d1 + (d2 - d1)*(log_x - log_e1)/ << 112 } << 113 else << 114 { << 115 value = data[nBins]; << 116 } << 117 return value; << 118 } << 119 << 120 76