File indexing completed on 2025-01-18 09:58:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef G4ParticleHPAngularP_h
0031 #define G4ParticleHPAngularP_h 1
0032
0033 #include "G4InterpolationManager.hh"
0034 #include "G4ParticleHPInterpolator.hh"
0035 #include "globals.hh"
0036
0037 #include <CLHEP/Units/SystemOfUnits.h>
0038
0039 class G4ParticleHPAngularP
0040 {
0041 public:
0042 G4ParticleHPAngularP()
0043 {
0044 theCosTh = nullptr;
0045 theProb = nullptr;
0046 theEnergy = 0.;
0047 nCoeff = 0;
0048 }
0049 ~G4ParticleHPAngularP()
0050 {
0051 delete[] theCosTh;
0052 delete[] theProb;
0053 }
0054
0055 inline void Init(std::istream& aDataFile)
0056 {
0057 G4double eNeu, cosTheta, probDist;
0058 G4int nProb;
0059 aDataFile >> eNeu >> nProb;
0060 theManager.Init(aDataFile);
0061 eNeu *= CLHEP::eV;
0062 Init(eNeu, nProb);
0063 for (G4int iii = 0; iii < nProb; iii++) {
0064 aDataFile >> cosTheta >> probDist;
0065 SetCosTh(iii, cosTheta);
0066 SetProb(iii, probDist);
0067 }
0068 }
0069
0070 inline void Init(G4double e, G4int n)
0071 {
0072 theCosTh = new G4double[n];
0073 theProb = new G4double[n];
0074 theEnergy = e;
0075 nCoeff = n;
0076 }
0077
0078 inline void SetEnergy(G4double energy) { theEnergy = energy; }
0079 inline void SetCosTh(G4int l, G4double coeff) { theCosTh[l] = coeff; }
0080 inline void SetProb(G4int l, G4double coeff) { theProb[l] = coeff; }
0081
0082 inline G4double GetCosTh(G4int l) { return theCosTh[l]; }
0083 inline G4double GetProb(G4int l) { return theProb[l]; }
0084 inline G4double GetEnergy() { return theEnergy; }
0085 inline G4int GetNumberOfPoints() { return nCoeff; }
0086 inline G4double GetCosTh()
0087 {
0088 G4int i;
0089 G4double rand = G4UniformRand();
0090 G4double run = 0, runo = 0;
0091 for (i = 0; i < GetNumberOfPoints(); i++) {
0092 runo = run;
0093 run += GetProb(i);
0094 if (run > rand) break;
0095 }
0096 if (i == GetNumberOfPoints()) i--;
0097 G4double costh =
0098 theInt.Interpolate(theManager.GetScheme(i), rand, runo, run, GetCosTh(i - 1), GetCosTh(i));
0099 return costh;
0100 }
0101
0102 private:
0103 G4double theEnergy;
0104 G4ParticleHPInterpolator theInt;
0105 G4int nCoeff;
0106 G4InterpolationManager theManager;
0107 G4double* theCosTh;
0108 G4double* theProb;
0109
0110 };
0111 #endif