500 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
501 G4cerr <<
" track has no particle definition associated."<<
G4endl;
507 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
508 G4cerr <<
" particle definiton has no decay table associated."<<
G4endl;
516 G4double theTotalActualWidth = this->EvaluateTotalActualWidth();
517 if (theTotalActualWidth !=0)
522 G4bool isChannelBelowThreshold =
true;
523 const G4int maxNumberOfLoops = 10000;
524 G4int loopCounter = 0;
530 G4int theNumberOfDaughters;
542 for (index = nChannels - 1; index >= 0; index--)
544 theSumActualWidth += theActualWidth[index];
545 theCumActualWidth[index] = theSumActualWidth;
553 for (index = nChannels - 1; index >= 0; index--)
555 if (r < theCumActualWidth[index])
564 delete [] theCumActualWidth;
568 G4cerr <<
"Error condition encountered in G4KineticTrack::Decay()"<<
G4endl;
569 G4cerr <<
" decay channel has 0x0 channel associated."<<
G4endl;
571 G4cerr <<
" channel index "<< chosench <<
"of "<<nChannels<<
"channels"<<
G4endl;
574 theParentName = theDecayChannel->GetParentName();
576 theBR = theActualWidth[index];
578 theNumberOfDaughters = theDecayChannel->GetNumberOfDaughters();
579 theDaughtersName1 =
"";
580 theDaughtersName2 =
"";
581 theDaughtersName3 =
"";
582 theDaughtersName4 =
"";
584 for (
G4int i=0; i < 4; i++) masses[i]=0.;
585 G4int shortlivedDaughters[4];
586 G4int numberOfShortliveds(0);
588 for (
G4int aD=0; aD < theNumberOfDaughters ; aD++)
594 shortlivedDaughters[numberOfShortliveds]=aD;
595 numberOfShortliveds++;
601 switch (theNumberOfDaughters)
606 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
607 theDaughtersName2 =
"";
608 theDaughtersName3 =
"";
609 theDaughtersName4 =
"";
612 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
613 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
614 theDaughtersName3 =
"";
615 theDaughtersName4 =
"";
616 if ( numberOfShortliveds == 1)
618 G4double massmax=theParentMass - SumLongLivedMass;
620 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
621 }
else if ( numberOfShortliveds == 2) {
626 G4double massmax=theParentMass - aSampler.
GetMinimumMass(theDecayChannel->GetDaughter(shortlivedDaughters[one]));
628 masses[shortlivedDaughters[zero]]=aSampler.
SampleMass(aDaughter,massmax);
629 massmax=theParentMass - masses[shortlivedDaughters[zero]];
630 aDaughter=theDecayChannel->GetDaughter(shortlivedDaughters[one]);
631 masses[shortlivedDaughters[one]]=aSampler.
SampleMass(aDaughter,massmax);
635 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
636 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
637 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
638 theDaughtersName4 =
"";
639 if ( numberOfShortliveds == 1)
641 G4double massmax=theParentMass - SumLongLivedMass;
643 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
647 theDaughtersName1 = theDecayChannel->GetDaughterName(0);
648 theDaughtersName2 = theDecayChannel->GetDaughterName(1);
649 theDaughtersName3 = theDecayChannel->GetDaughterName(2);
650 theDaughtersName4 = theDecayChannel->GetDaughterName(3);
651 if ( numberOfShortliveds == 1)
653 G4double massmax=theParentMass - SumLongLivedMass;
655 masses[shortlivedDaughters[0]]= aSampler.
SampleMass(aDaughter,massmax);
657 if ( theNumberOfDaughters > 4 ) {
659 ed <<
"More than 4 decay daughters: kept only the first 4" <<
G4endl;
669 for (
G4int i=0; i < 4; i++) sumDaughterMasses += masses[i];
670 if ( theParentMass - sumDaughterMasses > 0.0 ) isChannelBelowThreshold =
false;
672 }
while ( isChannelBelowThreshold && ++loopCounter < maxNumberOfLoops );
681 theNumberOfDaughters,
687 G4DecayProducts* theDecayProducts = thePhaseSpaceDecayChannel.DecayIt();
688 if(!theDecayProducts)
691 ed <<
"Error condition encountered: phase-space decay failed." << G4endl
692 <<
"\t the decaying particle is: " << thisDefinition->
GetParticleName() << G4endl
693 <<
"\t the channel index is: "<< chosench <<
" of "<< nChannels <<
"channels" << G4endl
694 <<
"\t " << theNumberOfDaughters <<
" daughter particles: "
695 << theDaughtersName1 <<
" " << theDaughtersName2 <<
" " << theDaughtersName3 <<
" "
696 << theDaughtersName4 <<
G4endl;
713 for (
G4int i=dEntries; i > 0; i--)
715 theDynamicParticle = theDecayProducts->
PopProducts();
719 momentumBalanceCMS += theDynamicParticle->
Get4Momentum();
721 energyMomentumBalance -= momentum;
726 delete theDynamicParticle;
728 delete theDecayProducts;
729 if(getenv(
"DecayEnergyBalanceCheck"))
730 std::cout <<
"DEBUGGING energy balance in cms and lab, charge baryon balance : "
731 << momentumBalanceCMS <<
" "
732 <<energyMomentumBalance <<
" "
736 return theDecayProductList;
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const
std::ostringstream G4ExceptionDescription
const G4ThreeVector & GetPosition() const
G4VDecayChannel * GetDecayChannel(G4int index) const
G4double GetActualMass() const
G4ParticleDefinition * GetDefinition() const
const G4String & GetParticleName() const
G4DecayTable * GetDecayTable() const
G4LorentzVector Get4Momentum() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4double GetMinimumMass(const G4ParticleDefinition *p) const
G4bool IsShortLived() const
G4double GetPDGMass() const
G4DynamicParticle * PopProducts()
const G4LorentzVector & Get4Momentum() const
G4double GetPDGCharge() const
const G4ParticleDefinition * GetDefinition() const
G4GLOB_DLL std::ostream G4cerr
G4int GetBaryonNumber() const