261{
262
263 if (actualMult.
Get() ==
nullptr) {
264 actualMult.
Get() =
new std::vector<G4int>(nDiscrete);
265 }
267 G4int nSecondaries = 0;
269
270 if (repFlag == 1) {
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);
277 if (current < 1) {
278 actualMult.
Get()->at(i) = 0;
280 }
281 }
282 nSecondaries += actualMult.
Get()->at(i);
283 }
284 for (i = 0; i < nSecondaries; ++i) {
287 thePhotons->push_back(theOne);
288 }
289
291
292 if (nDiscrete == 1 && nPartials == 1) {
293 if (actualMult.
Get()->at(0) > 0) {
294 if (disType[0] == 1) {
295
297 temp = partials[0]->
GetY(anEnergy);
299
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) {
307 }
308
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;
312 continue;
313 }
315 for (auto it = photons_e.cbegin(); it < photons_e.cend(); ++it) {
316 thePhotons->operator[](iphot)->SetKineticEnergy(
317 *it);
318
319
320 ++iphot;
321 }
322
323 break;
324 }
325 delete temp;
326 }
327 else {
328
329 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
330 }
331 ++count;
332 if (count > nSecondaries)
334 "G4ParticleHPPhotonDist::GetPhotons inconsistency");
335 }
336 }
337 else {
338 for (i = 0; i < nDiscrete; ++i) {
339 for (ii = 0; ii < actualMult.
Get()->at(i); ++ii) {
340 if (disType[i] == 1) {
341
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);
349 theP = iii;
350 if (random < run / sum) break;
351 }
352
353 if (theP == nPartials) theP = nPartials - 1;
354 sum = 0;
356 temp = partials[theP]->
GetY(anEnergy);
358 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
359 delete temp;
360 }
361 else {
362
363 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
364 }
365 ++count;
366 if (count > nSecondaries)
368 "G4ParticleHPPhotonDist::GetPhotons inconsistency");
369 }
370 }
371 }
372
373
374 if (isoFlag == 1) {
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);
384 }
385 }
386 else {
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;
391 }
392 if (ii == nDiscrete2)
393 --ii;
394
395 if (ii < nIso) {
396
397
398
399
401 G4double theta = std::acos(costheta);
404 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
405
406
407 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
408 en * costheta);
409 thePhotons->operator[](i)->SetMomentum(tempVector);
410 }
411 else if (tabulationType == 1) {
412
414 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
415 {
416 it = iii;
417 if (theLegendre[ii - nIso][iii].GetEnergy() > anEnergy) break;
418 }
420 aStore.SetCoeff(1, &(theLegendre[ii - nIso][it]));
421 if (it > 0) {
422 aStore.SetCoeff(0, &(theLegendre[ii - nIso][it - 1]));
423 }
424 else {
425 aStore.SetCoeff(0, &(theLegendre[ii - nIso][it]));
426 }
427 G4double cosTh = aStore.SampleMax(anEnergy);
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);
435 }
436 else {
437
439 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
440 {
441 it = iii;
442 if (theAngular[ii - nIso][iii].GetEnergy() > anEnergy) break;
443 }
448 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
449 G4ThreeVector tmpVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
450 en * costh);
451 thePhotons->operator[](i)->SetMomentum(tmpVector);
452 }
453 }
454 }
455 }
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];
461 }
464 for (i = 0; i < nGammaEnergies; ++i) {
465 it = i;
466 if (random < running[i] / running[nGammaEnergies - 1]) break;
467 }
468 delete[] running;
469 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
473 if (theInternalConversionFlag == 2 && random > thePhotonTransitionFraction[it]) {
475
476
477 totalEnergy +=
479 }
480 theOne->SetTotalEnergy(totalEnergy);
481 if (isoFlag == 1) {
483 G4double theta = std::acos(costheta);
486
487
488 G4double en = theOne->GetTotalMomentum();
489
490 G4ThreeVector temp(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
491 en * std::cos(theta));
492 theOne->SetMomentum(temp);
493 }
494 else {
495 G4double currentEnergy = theOne->GetTotalEnergy();
496 for (ii = 0; ii < nDiscrete2; ++ii) {
497 if (std::abs(currentEnergy - theGammas[ii]) < 0.1 * keV) break;
498 }
499 if (ii == nDiscrete2)
500 --ii;
501
502 if (ii < nIso) {
503
504
505
506
508
509
512
513
514 G4double en = theOne->GetTotalMomentum();
515
516 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
517 en * std::cos(theta));
518 theOne->SetMomentum(tempVector);
519 }
520 else if (tabulationType == 1) {
521
523 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
524 {
525 itt = iii;
526 if (theLegendre[ii - nIso][iii].GetEnergy() > anEnergy) break;
527 }
529 aStore.SetCoeff(1, &(theLegendre[ii - nIso][itt]));
530
531
532 if (itt > 0) {
533 aStore.SetCoeff(0, &(theLegendre[ii - nIso][itt - 1]));
534 }
535 else {
536 aStore.SetCoeff(0, &(theLegendre[ii - nIso][itt]));
537 }
538 G4double cosTh = aStore.SampleMax(anEnergy);
542
543
544 G4double en = theOne->GetTotalMomentum();
545
546 G4ThreeVector tempVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi),
547 en * std::cos(theta));
548 theOne->SetMomentum(tempVector);
549 }
550 else {
551
553 for (iii = 0; iii < nNeu[ii - nIso]; ++iii)
554 {
555 itt = iii;
556 if (theAngular[ii - nIso][iii].GetEnergy() > anEnergy) break;
557 }
562
563
564 G4double en = theOne->GetTotalMomentum();
565
566 G4ThreeVector tmpVector(en * sinth * std::cos(phi), en * sinth * std::sin(phi), en * costh);
567 theOne->SetMomentum(tmpVector);
568 }
569 }
570 thePhotons->push_back(theOne);
571 }
572 else if (repFlag == 0) {
573 if (thePartialXsec == nullptr) {
574 return thePhotons;
575 }
576
577
578
581 thePhotons->push_back(theOne);
582
583
584
586 std::vector<G4double> dif(nDiscrete, 0.0);
587 for (
G4int j = 0; j < nDiscrete; ++j) {
589 if (x > 0) {
590 sum += x;
591 }
592 dif[j] = sum;
593 }
594
596
598 for (
G4int j = 0; j < nDiscrete; ++j) {
600 if (dif[j] > y) {
601 iphoton = j;
602 break;
603 }
604 }
605
606
607
608 if (theReactionXsec != nullptr) {
609 if (thePartialXsec[iphoton].GetXsec(anEnergy) / theReactionXsec->
GetXsec(anEnergy)
611 {
612 delete thePhotons;
613 thePhotons = nullptr;
614 return thePhotons;
615 }
616 }
617
618
620
621 if (isoFlag == 1) {
622
623
625 }
626 else {
627 if (iphoton < nIso) {
628
629
631 }
632 else {
633 if (tabulationType == 1) {
634
635
637 for (
G4int j = 0; j < nNeu[iphoton - nIso]; ++j) {
638 iangle = j;
639 if (theLegendre[iphoton - nIso][j].GetEnergy() > anEnergy) break;
640 }
641
643 aStore.SetCoeff(1, &(theLegendre[iphoton - nIso][iangle]));
644 aStore.SetCoeff(0, &(theLegendre[iphoton - nIso][iangle - 1]));
645
646 cosTheta = aStore.SampleMax(anEnergy);
647 }
648 else if (tabulationType == 2) {
649
650
652 for (
G4int j = 0; j < nNeu[iphoton - nIso]; ++j) {
653 iangle = j;
654 if (theAngular[iphoton - nIso][j].GetEnergy() > anEnergy) break;
655 }
656 cosTheta = theAngular[iphoton - nIso][iangle].
GetCosTh();
657
658 }
659 }
660 }
661
662
664 G4double theta = std::acos(cosTheta);
665 G4double sinTheta = std::sin(theta);
666
667 G4double photonE = theGammas[iphoton];
668 G4ThreeVector direction(sinTheta * std::cos(phi), sinTheta * std::sin(phi), cosTheta);
670 thePhotons->operator[](0)->SetMomentum(photonP);
671 }
672 else {
673 delete thePhotons;
674 thePhotons = nullptr;
675 }
676 return thePhotons;
677}
G4long G4Poisson(G4double mean)
std::vector< G4ReactionProduct * > G4ReactionProductVector
static G4Electron * Electron()
G4double GetPDGMass() const
G4double GetCosTh(G4int l)
G4double GetY(G4int i, G4int j)
G4double GetXsec(G4int i)
G4double GetY(G4double x)
G4double GetX(G4int i) const
G4int GetVectorLength() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)