497{
498
499
500
501
502
503
504
505
506
508 if(!thisDefinition)
509 {
510 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
511 G4cerr <<
" track has no particle definition associated."<<
G4endl;
512 return 0;
513 }
515 if(!theDecayTable)
516 {
517 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
518 G4cerr <<
" particle definition has no decay table associated."<<
G4endl;
520 return 0;
521 }
522
526 G4double theTotalActualWidth = this->EvaluateTotalActualWidth();
527 if (theTotalActualWidth !=0)
528 {
529
530
531
532 G4bool isChannelBelowThreshold =
true;
533 const G4int maxNumberOfLoops = 10000;
534 G4int loopCounter = 0;
535
540 G4int theNumberOfDaughters;
546
547 do {
548
551 for (
G4int index = nChannels - 1; index >= 0; --index)
552 {
553 theSumActualWidth += theActualWidth[index];
554 theCumActualWidth[index] = theSumActualWidth;
555
556 }
557
558
561 chosench=-1;
562 for (
G4int index = nChannels - 1; index >= 0; --index)
563 {
564 if (r < theCumActualWidth[index])
565 {
567
568 chosench=index;
569 break;
570 }
571 }
572
573 delete [] theCumActualWidth;
574
575 if(!theDecayChannel)
576 {
577 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
578 G4cerr <<
" decay channel has 0x0 channel associated."<<
G4endl;
580 G4cerr <<
" channel index "<< chosench <<
"of "<<nChannels<<
"channels"<<
G4endl;
581 return 0;
582 }
583 theParentName = theDecayChannel->GetParentName();
585 theBR = theActualWidth[chosench];
586
587 theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
588 theDaughtersName1 = "";
589 theDaughtersName2 = "";
590 theDaughtersName3 = "";
591 theDaughtersName4 = "";
592
593 for (
G4int i=0; i < 4; ++i) masses[i]=0.;
594 G4int shortlivedDaughters[4];
595 G4int numberOfShortliveds(0);
597 for (
G4int aD=0; aD < theNumberOfDaughters ; ++aD)
598 {
602 {
603 shortlivedDaughters[numberOfShortliveds]=aD;
604 ++numberOfShortliveds;
605 } else {
607 }
608
609 }
610 switch (theNumberOfDaughters)
611 {
612 case 0:
613 break;
614 case 1:
615 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
616 theDaughtersName2 = "";
617 theDaughtersName3 = "";
618 theDaughtersName4 = "";
619 break;
620 case 2:
621 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
622 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
623 theDaughtersName3 = "";
624 theDaughtersName4 = "";
625 if ( numberOfShortliveds == 1)
627 G4double massmax=theParentMass - SumLongLivedMass;
629 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
630 } else if ( numberOfShortliveds == 2) {
631
635 G4double massmax=theParentMass - aSampler.
GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
637 masses[shortlivedDaughters[zero]]=aSampler.
SampleMass(aDaughter,massmax);
638 massmax=theParentMass - masses[shortlivedDaughters[zero]];
639 aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
640 masses[shortlivedDaughters[one]]=aSampler.
SampleMass(aDaughter,massmax);
641 }
642 break;
643 case 3:
644 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
645 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
646 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
647 theDaughtersName4 = "";
648 if ( numberOfShortliveds == 1)
650 G4double massmax=theParentMass - SumLongLivedMass;
652 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
653 }
654 break;
655 default:
656 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
657 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
658 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
659 theDaughtersName4 = theDecayChannel->GetDaughterName(3);
660 if ( numberOfShortliveds == 1)
662 G4double massmax=theParentMass - SumLongLivedMass;
664 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
665 }
666 if ( theNumberOfDaughters > 4 ) {
668 ed <<
"More than 4 decay daughters: kept only the first 4" <<
G4endl;
670 }
671 break;
672 }
673
674
675
676
678 for (
G4int i=0; i < 4; ++i) sumDaughterMasses += masses[i];
679 if ( theParentMass - sumDaughterMasses > 0.0 ) isChannelBelowThreshold = false;
680
681 } while ( isChannelBelowThreshold && ++loopCounter < maxNumberOfLoops );
682
683
684
685
686
688 theParentMass,
689 theBR,
690 theNumberOfDaughters,
691 theDaughtersName1,
692 theDaughtersName2,
693 theDaughtersName3,
694 theDaughtersName4,
695 masses);
696 G4DecayProducts* theDecayProducts = thePhaseSpaceDecayChannel.DecayIt();
697 if(!theDecayProducts)
698 {
700 ed <<
"Error condition encountered: phase-space decay failed." <<
G4endl
702 <<
"\t the channel index is: "<< chosench <<
" of "<< nChannels <<
"channels" <<
G4endl
703 << "\t " << theNumberOfDaughters << " daughter particles: "
704 << theDaughtersName1 << " " << theDaughtersName2 << " " << theDaughtersName3 << " "
705 << theDaughtersName4 <<
G4endl;
707 return 0;
708 }
709
710
711
712
713
714
724
726 for (
G4int i=dEntries; i > 0; --i)
727 {
728 theDynamicParticle = theDecayProducts->
PopProducts();
732 momentumBalanceCMS += theDynamicParticle->
Get4Momentum();
734 energyMomentumBalance -= momentum;
736 formationTime,
738 momentum);
739 if (aDaughter != nullptr)
740 {
744 }
745 theDecayProductList->push_back(aDaughter);
746 delete theDynamicParticle;
747 }
748 delete theDecayProducts;
749 if(std::getenv("DecayEnergyBalanceCheck"))
750 std::cout << "DEBUGGING energy balance in cms and lab, charge baryon balance : "
751 << momentumBalanceCMS << " "
752 <<energyMomentumBalance << " "
753 <<chargeBalance<<" "
754 <<baryonBalance<<" "
756 return theDecayProductList;
757 }
758 else
759 {
760 return 0;
761 }
762}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cerr
G4DynamicParticle * PopProducts()
G4ParticleDefinition * GetDefinition() const
G4LorentzVector Get4Momentum() const
void SetCreatorModelID(G4int id)
void SetParentResonanceID(const G4int parentID)
const G4LorentzVector & Get4Momentum() const
void SetParentResonanceDef(const G4ParticleDefinition *parent)
G4double GetPDGCharge() const
G4int GetBaryonNumber() const
const G4String & GetParticleName() const
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const