50 G4int low(0), high(0);
52 for (i0 = 0; i0 < nEnergy; i0++) {
54 if (theCoeff[i0].
GetEnergy() > anEnergy)
break;
56 low = std::max(0, high - 1);
60 x1 = theCoeff[low].GetEnergy();
61 x2 = theCoeff[high].GetEnergy();
68 for (i0 = 0; i0 < 601; i0++) {
71 for (m_tmp = 0; m_tmp < theCoeff[low].GetNumberOfPoly(); m_tmp++) {
73 try01 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(m_tmp) * theLeg.
Evaluate(l, costh);
75 if (try01 > max1) max1 = try01;
77 for (m_tmp = 0; m_tmp < theCoeff[high].GetNumberOfPoly(); m_tmp++) {
79 try02 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(m_tmp) * theLeg.
Evaluate(l, costh);
81 if (try02 > max2) max2 = try02;
88 G4int icounter_max = 1024;
91 if (icounter > icounter_max) {
92 G4cout <<
"Loop-counter exceeded the threshold value at " << __LINE__ <<
"th line of "
93 << __FILE__ <<
"." <<
G4endl;
99 for (m_tmp = 0; m_tmp < theCoeff[low].GetNumberOfPoly(); m_tmp++) {
102 v1 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(m_tmp) * legend;
104 for (m_tmp = 0; m_tmp < theCoeff[high].GetNumberOfPoly(); m_tmp++) {
107 v2 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(m_tmp) * legend;
113 if (0 >= theNorm)
break;
114 }
while (random > value / theNorm);
124 G4int low(0), high(0);
126 for (i0 = 0; i0 < nEnergy; i0++) {
128 if (theCoeff[i0].
GetEnergy() > anEnergy)
break;
130 low = std::max(0, high - 1);
134 x1 = theCoeff[low].GetEnergy();
135 x2 = theCoeff[high].GetEnergy();
142 for (i0 = 0; i0 < 601; i0++) {
145 for (l = 0; l < theCoeff[low].GetNumberOfPoly(); l++) {
146 try01 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(l) * theLeg.
Evaluate(l, costh);
148 if (try01 > max1) max1 = try01;
150 for (l = 0; l < theCoeff[high].GetNumberOfPoly(); l++) {
151 try02 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(l) * theLeg.
Evaluate(l, costh);
153 if (try02 > max2) max2 = try02;
160 G4int icounter_max = 1024;
163 if (icounter > icounter_max) {
164 G4cout <<
"Loop-counter exceeded the threshold value at " << __LINE__ <<
"th line of "
165 << __FILE__ <<
"." <<
G4endl;
171 for (l = 0; l < theCoeff[low].GetNumberOfPoly(); l++) {
173 v1 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(l) * legend;
175 for (l = 0; l < theCoeff[high].GetNumberOfPoly(); l++) {
177 v2 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(l) * legend;
179 v1 = std::max(0., v1);
180 v2 = std::max(0., v2);
183 if (0 >= theNorm)
break;
184 }
while (random > value / theNorm);
193 G4int low(0), high(0);
195 for (i0 = 0; i0 < nEnergy; i0++) {
197 if (theCoeff[i0].
GetEnergy() > anEnergy)
break;
199 low = std::max(0, high - 1);
203 x1 = theCoeff[low].GetEnergy();
204 x2 = theCoeff[high].GetEnergy();
206 G4double try01 = 0, try02 = 0, try11 = 0, try12 = 0;
209 for (l = 0; l < theCoeff[low].GetNumberOfPoly(); l++) {
210 try01 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(l) * theLeg.
Evaluate(l, -1.);
211 try11 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(l) * theLeg.
Evaluate(l, +1.);
213 for (l = 0; l < theCoeff[high].GetNumberOfPoly(); l++) {
214 try02 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(l) * theLeg.
Evaluate(l, -1.);
215 try12 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(l) * theLeg.
Evaluate(l, +1.);
219 theNorm = std::max(try1, try2);
224 G4int icounter_max = 1024;
227 if (icounter > icounter_max) {
228 G4cout <<
"Loop-counter exceeded the threshold value at " << __LINE__ <<
"th line of "
229 << __FILE__ <<
"." <<
G4endl;
235 for (l = 0; l < theCoeff[low].GetNumberOfPoly(); l++) {
237 v1 += (2. * l + 1) / 2. * theCoeff[low].
GetCoeff(l) * legend;
239 for (l = 0; l < theCoeff[high].GetNumberOfPoly(); l++) {
241 v2 += (2. * l + 1) / 2. * theCoeff[high].
GetCoeff(l) * legend;
245 }
while (random > value / theNorm);
253 G4int low(0), high(0);
255 for (i0 = 0; i0 < nEnergy; i0++) {
258 if (theCoeff[i0].
GetEnergy() > energy)
break;
260 low = std::max(0, high - 1);
265 x1 = theCoeff[low].GetEnergy();
266 x2 = theCoeff[high].GetEnergy();
269 for (i0 = 0; i0 < 601; i0++) {
274 theBuffer.
SetData(i0, costh, y);
279 for (i0 = 1; i0 < 601; i0++) {
281 if (rand < theBuffer.
GetY(i0) / theBuffer.
GetY(600))
break;
288 if (it == 601) it = 600;
291 if (norm == 0)
return -
DBL_MAX;
292 x1 = theBuffer.
GetY(it) / norm;
293 x2 = theBuffer.
GetY(it - 1) / norm;
294 y1 = theBuffer.
GetX(it);
295 y2 = theBuffer.
GetX(it - 1);
G4double Evaluate(G4int l, G4double costh)
G4double Integrate(G4int l, G4double costh)
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4double Sample(G4double energy)
G4double GetEnergy(G4int i)
G4double Integrate(G4int k, G4double costh)
G4double SampleDiscreteTwoBody(G4double anEnergy)
G4double GetCoeff(G4int i, G4int l)
G4double SampleMax(G4double energy)
G4double SampleElastic(G4double anEnergy)
void SetData(G4int i, G4double x, G4double y)
G4double GetY(G4double x)
G4double GetX(G4int i) const