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 #ifndef CCalDataSet_h 23 #ifndef CCalDataSet_h 27 #define CCalDataSet_h 24 #define CCalDataSet_h 28 25 29 #include "G4ParticleHPInterpolator.hh" << 26 #include "G4NeutronHPInterpolator.hh" 30 #include <vector> 27 #include <vector> 31 28 32 // by JPW, working, but to be cleaned up. @@@@ 29 // by JPW, working, but to be cleaned up. @@@@ 33 30 34 class CCalDataSet 31 class CCalDataSet 35 { 32 { 36 public: 33 public: 37 34 38 void insert(G4double anEnergy, G4double aXse << 35 void insert(double anEnergy, double aXsection) 39 { 36 { 40 pair<G4double, G4double> aPoint(anEnergy, << 37 pair<double, double> aPoint(anEnergy, aXsection); 41 theData.push_back(aPoint); 38 theData.push_back(aPoint); 42 } 39 } 43 40 44 double getCrossSection(G4double anEnergy) << 41 double getCrossSection(double anEnergy) 45 { 42 { 46 G4double result; << 43 double result; 47 if(anEnergy < theData[0].first) 44 if(anEnergy < theData[0].first) 48 { 45 { 49 result = 0; 46 result = 0; 50 } 47 } 51 else 48 else 52 { 49 { 53 G4double x1,x2; << 50 double x1,x2; 54 G4double y1,y2; << 51 double y1,y2; 55 if(anEnergy > theData[theData.size()-1]. 52 if(anEnergy > theData[theData.size()-1].second) 56 { 53 { 57 // extrapolation 54 // extrapolation 58 G4int n=theData.size(); << 55 int n=theData.size(); 59 x1 = theData[n-1].first; 56 x1 = theData[n-1].first; 60 y1 = theData[n-1].second; 57 y1 = theData[n-1].second; 61 x2 = theData[n-2].first; 58 x2 = theData[n-2].first; 62 y2 = theData[n-2].second; 59 y2 = theData[n-2].second; 63 } 60 } 64 else 61 else 65 { 62 { 66 // linear search and interpolation 63 // linear search and interpolation 67 unsigned int i; 64 unsigned int i; 68 for(i=0; i<theData.size(); ++i) << 65 for(i=0; i<theData.size(); i++) 69 { 66 { 70 if(theData[i].first>anEnergy) break; 67 if(theData[i].first>anEnergy) break; 71 } 68 } 72 x1 = theData[i-1].first; 69 x1 = theData[i-1].first; 73 y1 = theData[i-1].second; 70 y1 = theData[i-1].second; 74 x2 = theData[i].first; 71 x2 = theData[i].first; 75 y2 = theData[i].second; 72 y2 = theData[i].second; 76 } 73 } 77 // interpolate logarithmic in energy and 74 // interpolate logarithmic in energy and linear in cross-section 78 result = theInterpolator.Interpolate(LOG 75 result = theInterpolator.Interpolate(LOGLIN, anEnergy, x1,x2,y1,y2); 79 } 76 } 80 return result*barn; 77 return result*barn; 81 } 78 } 82 79 83 private: 80 private: 84 81 85 G4ParticleHPInterpolator theInterpolator; << 82 G4NeutronHPInterpolator theInterpolator; 86 83 87 private: 84 private: 88 85 89 vector<pair<G4double, G4double> > theData; << 86 vector<pair<double, double> > theData; 90 }; 87 }; 91 #endif 88 #endif 92 89