#include <G4ParticleHPArbitaryTab.hh>
Definition at line 46 of file G4ParticleHPArbitaryTab.hh.
◆ G4ParticleHPArbitaryTab()
G4ParticleHPArbitaryTab::G4ParticleHPArbitaryTab |
( |
| ) |
|
|
inline |
◆ ~G4ParticleHPArbitaryTab()
G4ParticleHPArbitaryTab::~G4ParticleHPArbitaryTab |
( |
| ) |
|
|
inlineoverride |
◆ GetFractionalProbability()
◆ Init()
void G4ParticleHPArbitaryTab::Init |
( |
std::istream & | theData | ) |
|
|
inlineoverridevirtual |
Implements G4VParticleHPEDis.
Definition at line 56 of file G4ParticleHPArbitaryTab.hh.
57 {
58 std::size_t i;
59 theFractionalProb.
Init(theData, CLHEP::eV);
60 theData >> nDistFunc;
61 const std::size_t dsize = nDistFunc > 0 ? nDistFunc : 1;
63 theManager.
Init(theData);
65 for (i = 0; i < dsize; ++i) {
66 theData >> currentEnergy;
67 theDistFunc[i].
SetLabel(currentEnergy * CLHEP::eV);
68 theDistFunc[i].
Init(theData, CLHEP::eV);
70
71
72
73
74
75 }
76
77
78
79
80 for (i = 0; i < dsize; ++i) {
82 theLowThreshold[i] = theDistFunc[i].
GetEnergy(0);
83 theHighThreshold[i] = theDistFunc[i].
GetEnergy(np - 1);
84 for (
G4int j = 0; j < np - 1; ++j) {
85 if (theDistFunc[i].GetXsec(j + 1) > 1.e-20) {
86 theLowThreshold[i] = theDistFunc[i].
GetEnergy(j);
87 break;
88 }
89 }
90 for (
G4int j = 1; j < np; ++j) {
91 if (theDistFunc[i].GetXsec(j - 1) > 1.e-20) {
92 theHighThreshold[i] = theDistFunc[i].
GetEnergy(j);
93 }
94 }
95 }
96
97 }
void Init(G4int aScheme, G4int aRange)
void IntegrateAndNormalise()
void SetLabel(G4double aLabel)
G4double GetEnergy(G4int i) const
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4int GetVectorLength() const
◆ Sample()
Implements G4VParticleHPEDis.
Definition at line 36 of file G4ParticleHPArbitaryTab.cc.
37{
39 for (i = 0; i < nDistFunc; i++) {
40 if (anEnergy < theDistFunc[i].GetLabel()) break;
41 }
42 G4int low(0), high(0);
43 if (i == nDistFunc) {
44 low = i - 2;
45 high = i - 1;
46 }
47 else if (i == 0) {
48 if (nDistFunc == 0) {
49 G4cerr <<
"No distribution functions to sample "
50 <<
"from in G4ParticleHPArbitaryTab::Sample" <<
G4endl;
52 }
53 return theDistFunc[0].
Sample();
54 }
55 else {
56 low = i - 1;
57 high = i;
58 }
59
60
61
62
63
64
65
66
67
70 G4double rval = (anEnergy - elow) / (ehigh - elow);
71 G4double eoutlow = theLowThreshold[low] + rval * (theLowThreshold[high] - theLowThreshold[low]);
73 theHighThreshold[low] + rval * (theHighThreshold[high] - theHighThreshold[low]);
76 if (rval < rand) {
77 Eout_1 = theDistFunc[low].
Sample();
78 Eout_2 = eoutlow
79 + (Eout_1 - theLowThreshold[low]) * (eouthigh - eoutlow)
80 / (theHighThreshold[low] - theLowThreshold[low]);
81 }
82 else {
83 Eout_1 = theDistFunc[high].
Sample();
84 Eout_2 = eoutlow
85 + (Eout_1 - theLowThreshold[high]) * (eouthigh - eoutlow)
86 / (theHighThreshold[high] - theLowThreshold[high]);
87 }
88 return Eout_2;
89
90
91}
G4GLOB_DLL std::ostream G4cerr
The documentation for this class was generated from the following files: