00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // neutron_hp -- source file 00027 // J.P. Wellisch, Nov-1996 00028 // A prototype of the low energy neutron transport model. 00029 // 00030 #include "G4NeutronHPList.hh" 00031 #include "G4HadronicException.hh" 00032 00033 void G4NeutronHPList::Check(G4int i) 00034 { 00035 if(i<0) 00036 { 00037 throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPList::Check(G4int) called with negative index"); 00038 } 00039 if(i>nEntries) throw G4HadronicException(__FILE__, __LINE__, "Skipped some index numbers in G4NeutronHPList"); 00040 if(i==nPoints) 00041 { 00042 nPoints = static_cast<G4int>(1.5*nPoints); 00043 G4double * buff = new G4double[nPoints]; 00044 for (G4int j=0; j<nEntries; j++) buff[j] = theData[j]; 00045 delete [] theData; 00046 theData = buff; 00047 } 00048 if(i==nEntries) nEntries++; 00049 } 00050 00051 void G4NeutronHPList::Init(std::ifstream & aDataFile, G4int nPar, G4double unit) 00052 { 00053 G4int i; 00054 G4double y; 00055 for (i=0; i<nPar; i++) 00056 { 00057 aDataFile >> y; 00058 SetValue(i,y*unit); 00059 } 00060 } 00061 00062 void G4NeutronHPList::Init(std::ifstream & aDataFile, G4double unit) 00063 { 00064 G4int total, i; 00065 aDataFile >> total; 00066 G4double y; 00067 for (i=0;i<total;i++) 00068 { 00069 aDataFile >>y; 00070 SetValue(i,y*unit); 00071 } 00072 } 00073 00074 G4double G4NeutronHPList::GetValue(G4int i) 00075 { 00076 // G4cout << "TestList "<<i<<" "<<nEntries<<G4endl; 00077 if(nEntries<0) 00078 { 00079 // G4cout <<nPoints<<" "<<nEntries<<" "<<theData<<G4endl; 00080 // for(G4int ii=0; ii<2; ii++) G4cout << theData[ii]<<" "; 00081 // G4cout << G4endl; 00082 } 00083 if (i<0) i=0; 00084 if(i>=GetListLength()) i=GetListLength()-1; 00085 return theData[i]; 00086 } 00087