#include <G4DistributionGenerator.hh>
Definition at line 41 of file G4DistributionGenerator.hh.
◆ G4DistributionGenerator() [1/2]
G4DistributionGenerator::G4DistributionGenerator |
( |
std::vector< G4double > & |
x, |
|
|
std::vector< G4double > & |
values |
|
) |
| |
Definition at line 42 of file G4DistributionGenerator.cc.
45{
47 _x = x;
48
49
50 if (x.size() != (values.size() + 1))
51 {
G4cout <<
" Inconsistent parameters in G4DistributionGenerator "
53 }
54 assert (x.size() == (values.size() + 1));
55
57 unsigned int i;
58 for (i=0; i<values.size(); i++) { tot += values[i]; }
59 assert (tot > 0.);
60
61 _cumProb.push_back(0.);
62
64 for (i=0; i<values.size(); i++)
65 {
66 sum += values[i];
67 _cumProb.push_back(sum / tot); }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82}
#define G4HadronicDeprecate(name)
G4DLLIMPORT std::ostream G4cout
◆ G4DistributionGenerator() [2/2]
G4DistributionGenerator::G4DistributionGenerator |
( |
| ) |
|
◆ ~G4DistributionGenerator()
G4DistributionGenerator::~G4DistributionGenerator |
( |
| ) |
|
◆ Generate()
Definition at line 91 of file G4DistributionGenerator.cc.
92{
94
95 G4int bin = _cumProb.size() - 1;
96 unsigned int i;
97 for (i=1; i<_cumProb.size(); i++)
98 {
99 if (ranflat >= _cumProb[i-1] && ranflat < _cumProb[i])
100 {
101 bin = i - 1;
102 }
103 }
104
105 if (bin >= 0 && bin <
static_cast<G4int>(_cumProb.size()-1) && bin <
static_cast<G4int>(_x.size()-1))
106 {
107 G4double coeff = (ranflat - _cumProb[bin]) * (_x[bin+1] - _x[bin]) /
108 (_cumProb[bin+1] - _cumProb[bin]);
109 xRandom = _x[bin] + coeff;
110
111
112
113
114
115
116
117 }
118 else
119 {
120
121
122
123
124
125
126
127
128 }
129
130 return xRandom;
131
132}
Referenced by G4PiMinusStopMaterial::P4Vector().
The documentation for this class was generated from the following files: