41 for (i=1; i<nLogs; i++)
45 logs.push_back(value);
72 G4int an_m = iso3In1 + iso3In2;
74 G4int jMinIn =
std::max(std::abs(isoIn1 - isoIn2), std::abs(an_m));
75 G4int jMaxIn = isoIn1 + isoIn2;
77 G4int jMinOut =
std::max(std::abs(isoOut1 - isoOut2), std::abs(an_m));
78 G4int jMaxOut = isoOut1 + isoOut2;
84 for (j=jMin; j<=jMax; j+=2)
110 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::ClebschGordan - sqrt of negative argument");
111 G4double coeff = std::sqrt(argument) / (std::pow(-1.,n));
132 std::vector<G4double>
n;
133 n.push_back(-j1 + j2 + j3);
134 n.push_back(j1 - m_1);
135 n.push_back(j1 + m_1);
136 n.push_back(j1 - j2 + j3);
137 n.push_back(j2 - m_2);
138 n.push_back(j2 + m_2);
139 n.push_back(j1 + j2 - j3);
140 n.push_back(j3 - m_3);
141 n.push_back(j3 + m_3);
149 G4double sum1 = n[i-1] + n[i+2] + n[i+5];
150 G4double sum2 = n[3*i-1] + n[3*i-2] + n[3*i-3];
151 if (sum1 != sigma || sum2 != sigma) ok =
false;
155 if (n[i+3*j-4] < 0.) ok =
false;
171 if (n[i+3*j-4] < smallest)
173 smallest = n[i+3*j-4];
184 for(
G4int j=1; j<=3; ++j)
187 n[j*3-3] = n[iMin+j*3-4];
190 sign = (
G4int) std::pow(-1.,sigma);
198 n[i-1] = n[i+jMin*3-4];
201 sign *= (
G4int) std::pow(-1.,sigma);
204 const std::vector<G4double>& logVector =
logs;
208 G4int logEntries = logVector.size() - 1;
209 for (i=0; i<n.size(); i++)
211 if (n[i] < 0. || n[i] > logEntries)
212 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::Wigner3J - Outside logVector boundaries, n");
236 if (sigma1 < 0. || sigma1 > logEntries)
237 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::Wigner3J - Outside logVector boundaries, sigma");
240 G4double hlp1 = (l2 + l3 + l4 +l7 -ls -l1 -l5 -l9 -l6 -l8) / 2.;
241 G4int expon =
static_cast<G4int>(r6 + r8+.00001);
242 G4double sgn = std::pow(-1., expon);
243 G4double coeff = std::exp(hlp1) * sgn;
245 G4int n61 =
static_cast<G4int>(r6 - r1+.00001);
246 if (n61 < 0. || n61 > logEntries)
247 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::Wigner3J - Outside logVector boundaries, n61");
248 G4int n81 =
static_cast<G4int>(r8 - r1+.00001);
249 if (n81 < 0. || n81 > logEntries)
250 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::Wigner3J - Outside logVector boundaries, n81");
252 G4double hlp2 = l6 - logVector[n61] + l8 - logVector[n81];
254 std::vector<G4double> S;
257 for (i=1; i<=n1; i++)
260 G4double den = i * (r6 - r1 + i) * (r8 - r1 + i);
263 G4double data = -last * (r1 + 1.0 - i) * (r5 + 1.0 - i) * (r9 + 1. - i) / den;
267 value = coeff * sum *
sign;
289 std::vector<G4double> temp;
294 if (isoIn1 == 0 && isoIn2 == 0)
296 G4cout <<
"WARNING: G4Clebsch::GenerateIso3 - both isoIn are zero" <<
G4endl;
302 G4int iso3 = iso3In1 + iso3In2;
308 temp.push_back(iso3);
313 temp.push_back(iso3);
319 G4int jMinIn =
std::max(std::abs(isoIn1 - isoIn2), std::abs(iso3));
320 G4int jMaxIn = isoIn1 + isoIn2;
324 G4int jMinOut = 9999;
327 for(i=-1; i<=1; i+=2)
329 for(j=-1; j<=1; j+=2)
331 jTmp= std::abs(i*isoA + j*isoB);
332 if(jTmp < jMinOut) jMinOut = jTmp;
335 jMinOut =
std::max(jMinOut, std::abs(iso3));
336 G4int jMaxOut = isoA + isoB;
347 G4int nJ = (jMax - jMin) / 2 + 1;
351 if ( (isoIn1 == 0 || isoIn2 == 0) && jMin != jMax )
352 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::GenerateIso3 - J1 or J2 = 0, but jMin != JMax");
356 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::GenerateIso3 - nJ is zero, no overlap between in and out");
361 std::vector<G4double> clebsch;
363 for(j=jMin; j<=jMax; j+=2)
366 clebsch.push_back(cg);
370 if (static_cast<G4int>(clebsch.size()) != nJ)
371 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::GenerateIso3 - nJ inconsistency");
381 throw G4HadronicException(__FILE__, __LINE__,
"G4Clebsch::GenerateIso3 - Sum of Clebsch-Gordan probabilities <=0");
385 std::vector<G4double> clebschPdf;
387 clebschPdf.push_back(previous/sum);
390 previous += clebsch[j];
392 clebschPdf.push_back(prob);
401 if (rand < clebschPdf[j])
411 std::vector<G4double> mMin;
412 mMin.push_back(-isoA);
413 mMin.push_back(-isoB);
415 std::vector<G4double> mMax;
416 mMax.push_back(isoA);
417 mMax.push_back(isoB);
421 std::vector<G4double> m1Out;
422 std::vector<G4double> m2Out;
424 const G4int size = 20;
427 G4int m1pos(0), m2pos(0);
429 G4int m1pr(0), m2pr(0);
432 for(j12 = std::abs(isoA-isoB); j12<=(isoA+isoB); j12+=2)
435 for (m1pr = static_cast<G4int>(mMin[0]+.00001); m1pr <= mMax[0]; m1pr+=2)
440 m1Out.push_back(m1pr);
442 for (m2pr = static_cast<G4int>(mMin[1]+.00001); m2pr <= mMax[1]; m2pr+=2)
449 m2Out.push_back(m2pr);
451 if(m1pr + m2pr == iso3)
453 G4int m12 = m1pr + m2pr;
458 prbout[m1pos][m2pos] = cleb;
463 prbout[m1pos][m2pos] = 0.;
472 for (i=0; i<size; i++)
474 for (j=0; j<size; j++)
484 for (m1p=0; m1p<m1pos; m1p++)
486 for (m2p=0; m2p<m2pos; m2p++)
488 if (rand < prbout[m1p][m2p])
490 temp.push_back(m1Out[m1p]);
491 temp.push_back(m2Out[m2p]);
496 rand -= prbout[m1p][m2p];
515 if(J1 == 0 || J2 == 0)
return cleb;
521 for(
G4int m1Current=-J1; m1Current<=J1; m1Current+=2)
523 G4int m2Current = M - m1Current;
527 if (m2Current == m_2 && m1Current == m_1) cleb += prob;
531 if (sum > 0.) cleb /= sum;
G4double NormalizedClebschGordan(G4int J, G4int m, G4int J1, G4int J2, G4int m1, G4int m2) const
std::vector< G4double > GenerateIso3(G4int isoIn1, G4int iso3In1, G4int isoIn2, G4int iso3In2, G4int isoOut1, G4int isoOut2) const
G4GLOB_DLL std::ostream G4cout
G4double Wigner3J(G4double j1, G4double j2, G4double j3, G4double m1, G4double m2, G4double m3) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
std::vector< G4double > logs
G4double Weight(G4int isoIn1, G4int iso3In1, G4int isoIn2, G4int iso3In2, G4int isoOut1, G4int isoOut2) const
G4bool operator!=(const G4Clebsch &right) const
G4bool operator==(const G4Clebsch &right) const
G4int sign(const T t)
A simple sign function that allows us to port fortran code to c++ more easily.
G4double ClebschGordan(G4int isoIn1, G4int iso3In1, G4int isoIn2, G4int iso3In2, G4int jOut) const