482{
483
484
485
486
487
488
489
490
491
493 if(!thisDefinition)
494 {
495 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
496 G4cerr <<
" track has no particle definition associated."<<
G4endl;
497 return 0;
498 }
500 if(!theDecayTable)
501 {
502 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
503 G4cerr <<
" particle definition has no decay table associated."<<
G4endl;
505 return 0;
506 }
507
511 G4double theTotalActualWidth = this->EvaluateTotalActualWidth();
512 if (theTotalActualWidth !=0)
513 {
514
515
516
517 G4bool isChannelBelowThreshold =
true;
518 const G4int maxNumberOfLoops = 10000;
519 G4int loopCounter = 0;
520
525 G4int theNumberOfDaughters;
531
532 do {
533
536 for (
G4int index = nChannels - 1; index >= 0; --index)
537 {
538 theSumActualWidth += theActualWidth[index];
539 theCumActualWidth[index] = theSumActualWidth;
540
541 }
542
543
546 chosench=-1;
547 for (
G4int index = nChannels - 1; index >= 0; --index)
548 {
549 if (r < theCumActualWidth[index])
550 {
552
553 chosench=index;
554 break;
555 }
556 }
557
558 delete [] theCumActualWidth;
559
560 if(!theDecayChannel)
561 {
562 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
563 G4cerr <<
" decay channel has 0x0 channel associated."<<
G4endl;
565 G4cerr <<
" channel index "<< chosench <<
"of "<<nChannels<<
"channels"<<
G4endl;
566 return 0;
567 }
568 theParentName = theDecayChannel->GetParentName();
570 theBR = theActualWidth[chosench];
571
572 theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
573 theDaughtersName1 = "";
574 theDaughtersName2 = "";
575 theDaughtersName3 = "";
576 theDaughtersName4 = "";
577
578 for (
G4int i=0; i < 4; ++i) masses[i]=0.;
579 G4int shortlivedDaughters[4];
580 G4int numberOfShortliveds(0);
582 for (
G4int aD=0; aD < theNumberOfDaughters ; ++aD)
583 {
587 {
588 shortlivedDaughters[numberOfShortliveds]=aD;
589 ++numberOfShortliveds;
590 } else {
592 }
593
594 }
595 switch (theNumberOfDaughters)
596 {
597 case 0:
598 break;
599 case 1:
600 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
601 theDaughtersName2 = "";
602 theDaughtersName3 = "";
603 theDaughtersName4 = "";
604 break;
605 case 2:
606 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
607 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
608 theDaughtersName3 = "";
609 theDaughtersName4 = "";
610 if ( numberOfShortliveds == 1)
612 G4double massmax=theParentMass - SumLongLivedMass;
614 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
615 } else if ( numberOfShortliveds == 2) {
616
620 G4double massmax=theParentMass - aSampler.
GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
622 masses[shortlivedDaughters[zero]]=aSampler.
SampleMass(aDaughter,massmax);
623 massmax=theParentMass - masses[shortlivedDaughters[zero]];
624 aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
625 masses[shortlivedDaughters[one]]=aSampler.
SampleMass(aDaughter,massmax);
626 }
627 break;
628 case 3:
629 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
630 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
631 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
632 theDaughtersName4 = "";
633 if ( numberOfShortliveds == 1)
635 G4double massmax=theParentMass - SumLongLivedMass;
637 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
638 }
639 break;
640 default:
641 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
642 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
643 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
644 theDaughtersName4 = theDecayChannel->GetDaughterName(3);
645 if ( numberOfShortliveds == 1)
647 G4double massmax=theParentMass - SumLongLivedMass;
649 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
650 }
651 if ( theNumberOfDaughters > 4 ) {
653 ed <<
"More than 4 decay daughters: kept only the first 4" <<
G4endl;
655 }
656 break;
657 }
658
659
660
661
663 for (
G4int i=0; i < 4; ++i) sumDaughterMasses += masses[i];
664 if ( theParentMass - sumDaughterMasses > 0.0 ) isChannelBelowThreshold = false;
665
666 } while ( isChannelBelowThreshold && ++loopCounter < maxNumberOfLoops );
667
668
669
670
671
673 theParentMass,
674 theBR,
675 theNumberOfDaughters,
676 theDaughtersName1,
677 theDaughtersName2,
678 theDaughtersName3,
679 theDaughtersName4,
680 masses);
681 G4DecayProducts* theDecayProducts = thePhaseSpaceDecayChannel.DecayIt();
682 if(!theDecayProducts)
683 {
685 ed <<
"Error condition encountered: phase-space decay failed." <<
G4endl
687 <<
"\t the channel index is: "<< chosench <<
" of "<< nChannels <<
"channels" <<
G4endl
688 << "\t " << theNumberOfDaughters << " daughter particles: "
689 << theDaughtersName1 << " " << theDaughtersName2 << " " << theDaughtersName3 << " "
690 << theDaughtersName4 <<
G4endl;
692 return 0;
693 }
694
695
696
697
707 for (
G4int i=dEntries; i > 0; --i)
708 {
709 theDynamicParticle = theDecayProducts->
PopProducts();
713 momentumBalanceCMS += theDynamicParticle->
Get4Momentum();
715 energyMomentumBalance -= momentum;
717 formationTime,
719 momentum));
720 delete theDynamicParticle;
721 }
722 delete theDecayProducts;
723 if(std::getenv("DecayEnergyBalanceCheck"))
724 std::cout << "DEBUGGING energy balance in cms and lab, charge baryon balance : "
725 << momentumBalanceCMS << " "
726 <<energyMomentumBalance << " "
727 <<chargeBalance<<" "
728 <<baryonBalance<<" "
730 return theDecayProductList;
731 }
732 else
733 {
734 return 0;
735 }
736}
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
const G4LorentzVector & Get4Momentum() const
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