59 if (aDataFile >> repFlag) {
60 aDataFile >> targetMass;
63 aDataFile >> nDiscrete;
64 const std::size_t msize = nDiscrete > 0 ? nDiscrete : 1;
65 disType =
new G4int[msize];
69 for (std::size_t i = 0; i < msize; ++i) {
70 aDataFile >> disType[i] >> energy[i];
72 theYield[i].
Init(aDataFile, eV);
75 else if (repFlag == 2) {
76 aDataFile >> theInternalConversionFlag;
77 aDataFile >> theBaseEnergy;
79 aDataFile >> theInternalConversionFlag;
80 aDataFile >> nGammaEnergies;
81 const std::size_t esize = nGammaEnergies > 0 ? nGammaEnergies : 1;
82 theLevelEnergies =
new G4double[esize];
83 theTransitionProbabilities =
new G4double[esize];
84 if (theInternalConversionFlag == 2)
85 thePhotonTransitionFraction =
new G4double[esize];
86 for (std::size_t ii = 0; ii < esize; ++ii) {
87 if (theInternalConversionFlag == 1) {
88 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii];
89 theLevelEnergies[ii] *= eV;
91 else if (theInternalConversionFlag == 2) {
92 aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii]
93 >> thePhotonTransitionFraction[ii];
94 theLevelEnergies[ii] *= eV;
98 "G4ParticleHPPhotonDist: Unknown conversion flag");
103 G4cout <<
"Data representation in G4ParticleHPPhotonDist: " << repFlag <<
G4endl;
105 __FILE__, __LINE__,
"G4ParticleHPPhotonDist: This data representation is not implemented.");
118 aDataFile >> isoFlag;
121 G4cout <<
"G4ParticleHPPhotonDist: repFlag == 2 && isoFlag != 1 is unexpected! If you use "
122 "G4ND3.x, then please report to Geant4 HyperNews. "
124 aDataFile >> tabulationType >> nDiscrete2 >> nIso;
125 if (theGammas !=
nullptr && nDiscrete2 != nDiscrete)
126 G4cout <<
"080731c G4ParticleHPPhotonDist nDiscrete2 != nDiscrete, It looks like something "
127 "wrong in your NDL files. Please update the latest. If you still have this "
128 "messages after the update, then please report to Geant4 Hyper News."
134 std::vector<G4double> vct_gammas_par;
135 std::vector<G4double> vct_shells_par;
136 std::vector<G4int> vct_primary_par;
137 std::vector<G4int> vct_distype_par;
138 std::vector<G4ParticleHPVector*> vct_pXS_par;
139 if (theGammas !=
nullptr && theShells !=
nullptr) {
141 for (i = 0; i < nDiscrete; ++i) {
142 vct_gammas_par.push_back(theGammas[i]);
143 vct_shells_par.push_back(theShells[i]);
144 vct_primary_par.push_back(isPrimary[i]);
145 vct_distype_par.push_back(disType[i]);
147 *hpv = thePartialXsec[i];
148 vct_pXS_par.push_back(hpv);
151 const std::size_t psize = nDiscrete2 > 0 ? nDiscrete2 : 1;
152 if (theGammas ==
nullptr) theGammas =
new G4double[psize];
153 if (theShells ==
nullptr) theShells =
new G4double[psize];
155 for (i = 0; i < nIso; ++i)
157 aDataFile >> theGammas[i] >> theShells[i];
161 const std::size_t tsize = nDiscrete2 - nIso > 0 ? nDiscrete2 - nIso : 1;
162 nNeu =
new G4int[tsize];
165 for (i = nIso; i < nDiscrete2; ++i) {
166 if (tabulationType == 1) {
167 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i - nIso];
170 const std::size_t lsize = nNeu[i - nIso] > 0 ? nNeu[i - nIso] : 1;
172 theLegendreManager.
Init(aDataFile);
173 for (ii = 0; ii < nNeu[i - nIso]; ++ii) {
174 theLegendre[i - nIso][ii].
Init(aDataFile);
177 else if (tabulationType == 2) {
178 aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i - nIso];
181 const std::size_t asize = nNeu[i - nIso] > 0 ? nNeu[i - nIso] : 1;
183 for (ii = 0; ii < nNeu[i - nIso]; ++ii) {
184 theAngular[i - nIso][ii].
Init(aDataFile);
190 __FILE__, __LINE__,
"cannot deal with this tabulation type for angular distributions.");
194 if (!vct_gammas_par.empty()) {
196 for (i = 0; i < nDiscrete; ++i) {
197 for (
G4int j = 0; j < nDiscrete; ++j) {
199 if (theGammas[i] == vct_gammas_par[j] && theShells[i] == vct_shells_par[j]) {
200 isPrimary[i] = vct_primary_par[j];
201 disType[i] = vct_distype_par[j];
202 thePartialXsec[i] = (*(vct_pXS_par[j]));
207 for (
auto it = vct_pXS_par.cbegin(); it != vct_pXS_par.cend(); ++it) {
263 if (actualMult.
Get() ==
nullptr) {
264 actualMult.
Get() =
new std::vector<G4int>(nDiscrete);
267 G4int nSecondaries = 0;
272 for (i = 0; i < nDiscrete; ++i) {
273 current = theYield[i].
GetY(anEnergy);
275 if (nDiscrete == 1 && current < 1.0001) {
276 actualMult.
Get()->at(i) =
static_cast<G4int>(current);
278 actualMult.
Get()->at(i) = 0;
282 nSecondaries += actualMult.
Get()->at(i);
284 for (i = 0; i < nSecondaries; ++i) {
287 thePhotons->push_back(theOne);
292 if (nDiscrete == 1 && nPartials == 1) {
293 if (actualMult.
Get()->at(0) > 0) {
294 if (disType[0] == 1) {
297 temp = partials[0]->
GetY(anEnergy);
300 std::vector<G4double> photons_e_best(actualMult.
Get()->at(0), 0.0);
303 for (
G4int j = 0; j < maxTry; ++j) {
304 std::vector<G4double> photons_e(actualMult.
Get()->at(0), 0.0);
305 for (
auto it = photons_e.begin(); it < photons_e.end(); ++it) {
309 if (std::accumulate(photons_e.cbegin(), photons_e.cend(), 0.0) > maximumE) {
310 if (std::accumulate(photons_e.cbegin(), photons_e.cend(), 0.0) < best)
311 photons_e_best = photons_e;
315 for (
auto it = photons_e.cbegin(); it < photons_e.cend(); ++it) {
316 thePhotons->operator[](iphot)->SetKineticEnergy(
329 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
332 if (count > nSecondaries)
334 "G4ParticleHPPhotonDist::GetPhotons inconsistency");
338 for (i = 0; i < nDiscrete; ++i) {
339 for (ii = 0; ii < actualMult.
Get()->at(i); ++ii) {
340 if (disType[i] == 1) {
343 for (iii = 0; iii < nPartials; ++iii)
344 sum += probs[iii].GetY(anEnergy);
347 for (iii = 0; iii < nPartials; ++iii) {
348 run += probs[iii].
GetY(anEnergy);
350 if (random < run / sum)
break;
353 if (theP == nPartials) theP = nPartials - 1;
356 temp = partials[theP]->
GetY(anEnergy);
358 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
363 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
366 if (count > nSecondaries)
368 "G4ParticleHPPhotonDist::GetPhotons inconsistency");
375 for (i = 0; i < nSecondaries; ++i) {
377 G4double theta = std::acos(costheta);
380 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
381 G4ThreeVector temp(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
382 en * std::cos(theta));
383 thePhotons->operator[](i)->SetMomentum(temp);
387 for (i = 0; i < nSecondaries; ++i) {
388 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
389 for (ii = 0; ii < nDiscrete2; ++ii) {
390 if (std::abs(currentEnergy - theGammas[ii]) < 0.1 * keV)
break;
392 if (ii == nDiscrete2)
401 G4double theta = std::acos(costheta);
404 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
407 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
409 thePhotons->operator[](i)->SetMomentum(tempVector);
411 else if (tabulationType == 1) {
414 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
417 if (theLegendre[ii - nIso][iii].GetEnergy() > anEnergy)
break;
420 aStore.
SetCoeff(1, &(theLegendre[ii - nIso][it]));
422 aStore.
SetCoeff(0, &(theLegendre[ii - nIso][it - 1]));
425 aStore.
SetCoeff(0, &(theLegendre[ii - nIso][it]));
431 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
432 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
433 en * std::cos(theta));
434 thePhotons->operator[](i)->SetMomentum(tempVector);
439 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
442 if (theAngular[ii - nIso][iii].GetEnergy() > anEnergy)
break;
448 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
449 G4ThreeVector tmpVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
451 thePhotons->operator[](i)->SetMomentum(tmpVector);
456 else if (repFlag == 2) {
457 auto running =
new G4double[nGammaEnergies];
458 running[0] = theTransitionProbabilities[0];
459 for (i = 1; i < nGammaEnergies; ++i) {
460 running[i] = running[i - 1] + theTransitionProbabilities[i];
464 for (i = 0; i < nGammaEnergies; ++i) {
466 if (random < running[i] / running[nGammaEnergies - 1])
break;
469 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
473 if (theInternalConversionFlag == 2 && random > thePhotonTransitionFraction[it]) {
480 theOne->SetTotalEnergy(totalEnergy);
483 G4double theta = std::acos(costheta);
488 G4double en = theOne->GetTotalMomentum();
490 G4ThreeVector temp(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
491 en * std::cos(theta));
492 theOne->SetMomentum(temp);
495 G4double currentEnergy = theOne->GetTotalEnergy();
496 for (ii = 0; ii < nDiscrete2; ++ii) {
497 if (std::abs(currentEnergy - theGammas[ii]) < 0.1 * keV)
break;
499 if (ii == nDiscrete2)
514 G4double en = theOne->GetTotalMomentum();
516 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
517 en * std::cos(theta));
518 theOne->SetMomentum(tempVector);
520 else if (tabulationType == 1) {
523 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
526 if (theLegendre[ii - nIso][iii].GetEnergy() > anEnergy)
break;
529 aStore.
SetCoeff(1, &(theLegendre[ii - nIso][itt]));
533 aStore.
SetCoeff(0, &(theLegendre[ii - nIso][itt - 1]));
536 aStore.
SetCoeff(0, &(theLegendre[ii - nIso][itt]));
544 G4double en = theOne->GetTotalMomentum();
546 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
547 en * std::cos(theta));
548 theOne->SetMomentum(tempVector);
553 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
556 if (theAngular[ii - nIso][iii].GetEnergy() > anEnergy)
break;
564 G4double en = theOne->GetTotalMomentum();
566 G4ThreeVector tmpVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi), en * costh);
567 theOne->SetMomentum(tmpVector);
570 thePhotons->push_back(theOne);
572 else if (repFlag == 0) {
573 if (thePartialXsec ==
nullptr) {
581 thePhotons->push_back(theOne);
586 std::vector<G4double> dif(nDiscrete, 0.0);
587 for (
G4int j = 0; j < nDiscrete; ++j) {
598 for (
G4int j = 0; j < nDiscrete; ++j) {
608 if (theReactionXsec !=
nullptr) {
609 if (thePartialXsec[iphoton].GetXsec(anEnergy) / theReactionXsec->
GetXsec(anEnergy)
613 thePhotons =
nullptr;
627 if (iphoton < nIso) {
633 if (tabulationType == 1) {
637 for (
G4int j = 0; j < nNeu[iphoton - nIso]; ++j) {
639 if (theLegendre[iphoton - nIso][j].GetEnergy() > anEnergy)
break;
643 aStore.
SetCoeff(1, &(theLegendre[iphoton - nIso][iangle]));
644 aStore.
SetCoeff(0, &(theLegendre[iphoton - nIso][iangle - 1]));
648 else if (tabulationType == 2) {
652 for (
G4int j = 0; j < nNeu[iphoton - nIso]; ++j) {
654 if (theAngular[iphoton - nIso][j].GetEnergy() > anEnergy)
break;
656 cosTheta = theAngular[iphoton - nIso][iangle].
GetCosTh();
664 G4double theta = std::acos(cosTheta);
665 G4double sinTheta = std::sin(theta);
667 G4double photonE = theGammas[iphoton];
668 G4ThreeVector direction(sinTheta * std::cos(phi), sinTheta * std::sin(phi), cosTheta);
670 thePhotons->operator[](0)->SetMomentum(photonP);
674 thePhotons =
nullptr;