00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef G4NeutronHPAngularP_h
00030 #define G4NeutronHPAngularP_h 1
00031
00032 #include <CLHEP/Units/SystemOfUnits.h>
00033
00034 #include "globals.hh"
00035 #include "G4InterpolationManager.hh"
00036
00037 class G4NeutronHPAngularP
00038 {
00039 public:
00040
00041 G4NeutronHPAngularP()
00042 {
00043 theCosTh = 0;
00044 theProb = 0;
00045 }
00046 ~G4NeutronHPAngularP()
00047 {
00048 if(theCosTh!=0) delete [] theCosTh;
00049 if(theProb!=0) delete [] theProb;
00050 }
00051
00052 inline void Init(std::ifstream & aDataFile)
00053 {
00054 G4double eNeu, cosTheta, probDist;
00055 G4int nProb;
00056 aDataFile >> eNeu >> nProb;
00057 theManager.Init(aDataFile);
00058 eNeu *= CLHEP::eV;
00059 Init(eNeu, nProb);
00060 for (G4int iii=0; iii<nProb; iii++)
00061 {
00062 aDataFile >> cosTheta >> probDist;
00063 SetCosTh(iii, cosTheta);
00064 SetProb(iii,probDist);
00065 }
00066 }
00067
00068 inline void Init(G4double e, G4int n)
00069 {
00070 theCosTh = new G4double[n];
00071 theProb = new G4double[n];
00072 theEnergy = e;
00073 nCoeff = n;
00074 }
00075
00076 inline void SetEnergy(G4double energy){ theEnergy = energy; }
00077 inline void SetCosTh(G4int l, G4double coeff) {theCosTh[l]=coeff;}
00078 inline void SetProb(G4int l, G4double coeff) {theProb[l]=coeff;}
00079
00080 inline G4double GetCosTh(G4int l) {return theCosTh[l];}
00081 inline G4double GetProb(G4int l) {return theProb[l];}
00082 inline G4double GetEnergy(){return theEnergy;}
00083 inline G4int GetNumberOfPoints(){ return nCoeff; }
00084 inline G4double GetCosTh()
00085 {
00086 G4int i;
00087 G4double rand = G4UniformRand();
00088 G4double run=0, runo=0;
00089 for (i=0; i<GetNumberOfPoints(); i++)
00090 {
00091 runo=run;
00092 run += GetProb(i);
00093 if(run>rand) break;
00094 }
00095 if(i == GetNumberOfPoints()) i--;
00096 G4double costh = theInt.Interpolate(theManager.GetScheme(i), rand,
00097 runo, run, GetCosTh(i-1), GetCosTh(i));
00098 return costh;
00099 }
00100
00101 private:
00102
00103 G4double theEnergy;
00104 G4NeutronHPInterpolator theInt;
00105 G4int nCoeff;
00106 G4InterpolationManager theManager;
00107 G4double * theCosTh;
00108 G4double * theProb;
00109
00110 };
00111 #endif