[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 | // |
---|
| 27 | // $Id: G4NeutronHPAngularP.hh,v 1.11 2007/06/06 12:45:13 ahoward Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | #ifndef G4NeutronHPAngularP_h |
---|
| 31 | #define G4NeutronHPAngularP_h 1 |
---|
| 32 | |
---|
| 33 | #include "globals.hh" |
---|
| 34 | #include "G4InterpolationManager.hh" |
---|
| 35 | |
---|
| 36 | class G4NeutronHPAngularP |
---|
| 37 | { |
---|
| 38 | public: |
---|
| 39 | |
---|
| 40 | G4NeutronHPAngularP() |
---|
| 41 | { |
---|
| 42 | theCosTh = 0; |
---|
| 43 | theProb = 0; |
---|
| 44 | } |
---|
| 45 | ~G4NeutronHPAngularP() |
---|
| 46 | { |
---|
| 47 | if(theCosTh!=0) delete [] theCosTh; |
---|
| 48 | if(theProb!=0) delete [] theProb; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | inline void Init(std::ifstream & aDataFile) |
---|
| 52 | { |
---|
| 53 | G4double eNeu, cosTheta, probDist; |
---|
| 54 | G4int nProb; |
---|
| 55 | aDataFile >> eNeu >> nProb; |
---|
| 56 | theManager.Init(aDataFile); |
---|
| 57 | eNeu *= eV; |
---|
| 58 | Init(eNeu, nProb); |
---|
| 59 | for (G4int iii=0; iii<nProb; iii++) |
---|
| 60 | { |
---|
| 61 | aDataFile >> cosTheta >> probDist; |
---|
| 62 | SetCosTh(iii, cosTheta); |
---|
| 63 | SetProb(iii,probDist); |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | inline void Init(G4double e, G4int n) |
---|
| 68 | { |
---|
| 69 | theCosTh = new G4double[n]; |
---|
| 70 | theProb = new G4double[n]; |
---|
| 71 | theEnergy = e; |
---|
| 72 | nCoeff = n; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | inline void SetEnergy(G4double energy){ theEnergy = energy; } |
---|
| 76 | inline void SetCosTh(G4int l, G4double coeff) {theCosTh[l]=coeff;} |
---|
| 77 | inline void SetProb(G4int l, G4double coeff) {theProb[l]=coeff;} |
---|
| 78 | |
---|
| 79 | inline G4double GetCosTh(G4int l) {return theCosTh[l];} |
---|
| 80 | inline G4double GetProb(G4int l) {return theProb[l];} |
---|
| 81 | inline G4double GetEnergy(){return theEnergy;} |
---|
| 82 | inline G4int GetNumberOfPoints(){ return nCoeff; } |
---|
| 83 | inline G4double GetCosTh() |
---|
| 84 | { |
---|
| 85 | G4int i; |
---|
| 86 | G4double rand = G4UniformRand(); |
---|
| 87 | G4double run=0, runo=0; |
---|
| 88 | for (i=0; i<GetNumberOfPoints(); i++) |
---|
| 89 | { |
---|
| 90 | runo=run; |
---|
| 91 | run += GetProb(i); |
---|
| 92 | if(run>rand) break; |
---|
| 93 | } |
---|
| 94 | if(i == GetNumberOfPoints()) i--; |
---|
| 95 | G4double costh = theInt.Interpolate(theManager.GetScheme(i), rand, |
---|
| 96 | runo, run, GetCosTh(i-1), GetCosTh(i)); |
---|
| 97 | return costh; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | private: |
---|
| 101 | |
---|
| 102 | G4double theEnergy; // neutron energy |
---|
| 103 | G4NeutronHPInterpolator theInt; // knows tointerpolate |
---|
| 104 | G4int nCoeff; |
---|
| 105 | G4InterpolationManager theManager; // knows the interpolation between stores |
---|
| 106 | G4double * theCosTh; |
---|
| 107 | G4double * theProb; // probability distribution as fcn of theta |
---|
| 108 | // integral normalised to 1. |
---|
| 109 | }; |
---|
| 110 | #endif |
---|