[819] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // neutron_hp -- source file |
---|
| 27 | // J.P. Wellisch, Nov-1996 |
---|
| 28 | // A prototype of the low energy neutron transport model. |
---|
| 29 | // |
---|
| 30 | #include "G4NeutronHPList.hh" |
---|
| 31 | #include "G4HadronicException.hh" |
---|
| 32 | |
---|
| 33 | void G4NeutronHPList::Check(G4int i) |
---|
| 34 | { |
---|
| 35 | if(i<0) |
---|
| 36 | { |
---|
| 37 | throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPList::Check(G4int) called with negative index"); |
---|
| 38 | } |
---|
| 39 | if(i>nEntries) throw G4HadronicException(__FILE__, __LINE__, "Skipped some index numbers in G4NeutronHPList"); |
---|
| 40 | if(i==nPoints) |
---|
| 41 | { |
---|
| 42 | nPoints = static_cast<G4int>(1.5*nPoints); |
---|
| 43 | G4double * buff = new G4double[nPoints]; |
---|
| 44 | for (G4int j=0; j<nEntries; j++) buff[j] = theData[j]; |
---|
| 45 | delete [] theData; |
---|
| 46 | theData = buff; |
---|
| 47 | } |
---|
| 48 | if(i==nEntries) nEntries++; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void G4NeutronHPList::Init(std::ifstream & aDataFile, G4int nPar, G4double unit) |
---|
| 52 | { |
---|
| 53 | G4int i; |
---|
| 54 | G4double y; |
---|
| 55 | for (i=0; i<nPar; i++) |
---|
| 56 | { |
---|
| 57 | aDataFile >> y; |
---|
| 58 | SetValue(i,y*unit); |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | void G4NeutronHPList::Init(std::ifstream & aDataFile, G4double unit) |
---|
| 63 | { |
---|
| 64 | G4int total, i; |
---|
| 65 | aDataFile >> total; |
---|
| 66 | G4double y; |
---|
| 67 | for (i=0;i<total;i++) |
---|
| 68 | { |
---|
| 69 | aDataFile >>y; |
---|
| 70 | SetValue(i,y*unit); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | G4double G4NeutronHPList::GetValue(G4int i) |
---|
| 75 | { |
---|
| 76 | // G4cout << "TestList "<<i<<" "<<nEntries<<G4endl; |
---|
| 77 | if(nEntries<0) |
---|
| 78 | { |
---|
| 79 | // G4cout <<nPoints<<" "<<nEntries<<" "<<theData<<G4endl; |
---|
| 80 | // for(G4int ii=0; ii<2; ii++) G4cout << theData[ii]<<" "; |
---|
| 81 | // G4cout << G4endl; |
---|
| 82 | } |
---|
| 83 | if (i<0) i=0; |
---|
| 84 | if(i>=GetListLength()) i=GetListLength()-1; |
---|
| 85 | return theData[i]; |
---|
| 86 | } |
---|
| 87 | |
---|