146 using namespace CLHEP;
151 #ifdef G4MULTITHREADED
159 forceDecayDirection(0.,0.,0.), forceDecayHalfAngle(0.*
deg), verboseLevel(0)
163 G4cout <<
"G4RadioactiveDecay constructor: processName = " << processName
177 #ifdef G4MULTITHREADED
178 G4AutoLock lk(&G4RadioactiveDecay::radioactiveDecayMutex);
214 for (DecayTableMap::iterator i =
dkmap->begin(); i !=
dkmap->end(); i++) {
225 if (((
const G4Ions*)(&aParticle))->GetExcitationEnergy() > 0.) {
return true;}
234 G4int A = ((
const G4Ions*) (&aParticle))->GetAtomicMass();
235 G4int Z = ((
const G4Ions*) (&aParticle))->GetAtomicNumber();
246 DecayTableMap::iterator table_ptr =
dkmap->find(key);
249 if (table_ptr ==
dkmap->end() ) {
251 (*dkmap)[key] = theDecayTable;
253 theDecayTable = table_ptr->second;
256 return theDecayTable;
265 for (
size_t i = 0; i < theLogicalVolumes->size(); i++) {
266 volume=(*theLogicalVolumes)[i];
267 if (volume->
GetName() == aVolume) {
275 }
else if(i == theLogicalVolumes->size()) {
276 G4cerr <<
"SelectAVolume: "<< aVolume
277 <<
" is not a valid logical volume name" <<
G4endl;
288 for (
size_t i = 0; i < theLogicalVolumes->size(); i++){
289 volume=(*theLogicalVolumes)[i];
290 if (volume->
GetName() == aVolume) {
291 std::vector<G4String>::iterator location;
298 G4cerr <<
" DeselectVolume:" << aVolume <<
" is not in the list "
303 G4cout <<
" DeselectVolume: " << aVolume <<
" is removed from list "
306 }
else if (i == theLogicalVolumes->size()) {
307 G4cerr <<
" DeselectVolume:" << aVolume
308 <<
"is not a valid logical volume name" <<
G4endl;
324 for (
size_t i = 0; i < theLogicalVolumes->size(); i++){
325 volume = (*theLogicalVolumes)[i];
375 G4cout <<
"The DecayRate Table for " << aParticleName <<
" is selected."
389 long double taotime = 0.L;
398 ed <<
" While count exceeded " <<
G4endl;
399 while (t >
SBin[nbin]) {
411 long double ltao = tao;
414 for (
G4int i = 0; i < nbin; i++) {
415 taotime += (
long double)
SProfile[i] *
416 (std::exp(-(lt-(
long double)
SBin[i+1])/ltao)-std::exp(-(lt-(
long double)
SBin[i])/ltao));
419 taotime += (
long double)
SProfile[nbin] * (1.
L-std::exp(-(lt-(
long double)
SBin[nbin])/ltao));
424 G4cout <<
" Tao time =: " <<taotime <<
" reset to zero!"<<
G4endl;
562 ed <<
" While count exceeded " <<
G4endl;
576 G4cout <<
" Decay time: " <<decaytime/
s <<
"[s]" <<G4endl;
588 ed <<
" While count exceeded " <<
G4endl;
589 while ( aDecayTime >
DBin[i] ) {
621 G4cout <<
"G4RadioactiveDecay::GetMeanLifeTime() " <<
G4endl;
623 <<
" GeV, Mass: " << theParticle->
GetMass()/
GeV
624 <<
" GeV, Life time: " << theLife/
ns <<
" ns " <<
G4endl;
628 else if (theLife < 0.0) {meanlife =
DBL_MAX;}
629 else {meanlife = theLife;}
632 if (((
const G4Ions*)(theParticleDef))->GetExcitationEnergy() > 0. &&
633 meanlife ==
DBL_MAX) {meanlife = 0.;}
637 G4cout <<
" mean life time: " << meanlife/
s <<
" s " <<
G4endl;
659 G4cout <<
"G4RadioactiveDecay::GetMeanFreePath() " <<
G4endl;
661 <<
" GeV, Mass: " << aMass/
GeV <<
" GeV, tau: " << tau <<
" ns "
672 }
else if (tau < 0.0) {
675 ed <<
"Ion has negative lifetime " << tau
676 <<
" but is not stable. Setting mean free path to DBL_MAX" <<
G4endl;
677 G4Exception(
"G4RadioactiveDecay::GetMeanFreePath()",
"HAD_RDM_011",
684 pathlength = c_light*tau*betaGamma;
690 G4cout <<
"G4Decay::GetMeanFreePath: "
692 <<
" stops, kinetic energy = "
702 G4cout <<
"mean free path: "<< pathlength/
m <<
" m" <<
G4endl;
743 G4int A = ((
const G4Ions*)(&theParentNucleus))->GetAtomicMass();
744 G4int Z = ((
const G4Ions*)(&theParentNucleus))->GetAtomicNumber();
745 G4double levelEnergy = ((
const G4Ions*)(&theParentNucleus))->GetExcitationEnergy();
748 #ifdef G4MULTITHREADED
749 G4AutoLock lk(&G4RadioactiveDecay::radioactiveDecayMutex);
752 DecayTableMap::iterator master_table_ptr = master_dkmap->find(key);
754 if (master_table_ptr != master_dkmap->end() ) {
755 return master_table_ptr->second;
766 if (!getenv(
"G4RADIOACTIVEDATA") ) {
767 G4cout <<
"Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files."
769 throw G4HadronicException(__FILE__, __LINE__,
" Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files.");
771 G4String dirName = getenv(
"G4RADIOACTIVEDATA");
773 std::ostringstream os;
774 os <<dirName <<
"/z" <<Z <<
".a" <<A <<
'\0';
778 std::ifstream DecaySchemeFile(file);
781 if (DecaySchemeFile) {
783 const G4int nMode = 9;
784 G4bool modeFirstRecord[nMode];
785 G4double modeTotalBR[nMode] = {0.0};
787 for (
G4int i = 0; i < nMode; i++) {
788 modeFirstRecord[i] =
true;
793 char inputChars[100]={
' '};
807 ed <<
" While count exceeded " <<
G4endl;
809 while (!complete && !DecaySchemeFile.getline(inputChars, 100).eof()) {
816 inputLine = inputChars;
817 inputLine = inputLine.
strip(1);
818 if (inputChars[0] !=
'#' && inputLine.length() != 0) {
819 std::istringstream tmpStream(inputLine);
821 if (inputChars[0] ==
'P') {
824 tmpStream >> recordType >> a >> b;
834 if (inputChars[0] ==
'W') {
838 G4cout <<
" Warning in G4RadioactiveDecay::LoadDecayTable " <<
G4endl;
844 tmpStream >> theDecayMode >> a >> b >> c >> betaType;
847 if (inputLine.length() < 80) betaType =
allowed;
851 switch (theDecayMode) {
860 theDecayTable->
Insert(anITChannel);
866 if (modeFirstRecord[1]) {
867 modeFirstRecord[1] =
false;
875 theDecayTable->
Insert(aBetaMinusChannel);
883 if (modeFirstRecord[2]) {
884 modeFirstRecord[2] =
false;
892 theDecayTable->
Insert(aBetaPlusChannel);
900 if (modeFirstRecord[3]) {
901 modeFirstRecord[3] =
false;
909 theDecayTable->
Insert(aKECChannel);
916 if (modeFirstRecord[4]) {
917 modeFirstRecord[4] =
false;
925 theDecayTable->
Insert(aLECChannel);
932 if (modeFirstRecord[5]) {
933 modeFirstRecord[5] =
false;
941 theDecayTable->
Insert(aMECChannel);
947 if (modeFirstRecord[6]) {
948 modeFirstRecord[6] =
false;
955 theDecayTable->
Insert(anAlphaChannel);
961 if (modeFirstRecord[7]) {
962 modeFirstRecord[7] =
false;
969 theDecayTable->
Insert(aProtonChannel);
975 if (modeFirstRecord[8]) {
976 modeFirstRecord[8] =
false;
983 theDecayTable->
Insert(aNeutronChannel);
1018 G4Exception(
"G4RadioactiveDecay::LoadDecayTable()",
"HAD_RDM_000",
1036 theNuclearDecayChannel =
static_cast<G4NuclearDecay*
>(theChannel);
1039 if (theDecayMode !=
IT) {
1040 theBR = theChannel->
GetBR();
1041 theChannel->
SetBR(theBR*modeTotalBR[theDecayMode]/modeSumBR[theDecayMode]);
1045 DecaySchemeFile.close();
1047 if (!found && levelEnergy > 0) {
1053 theDecayTable->
Insert(anITChannel);
1055 if (!theDecayTable) {
1058 G4cerr <<
"G4RadoactiveDecay::LoadDecayTable() : cannot find ion radioactive decay file "
1061 return theDecayTable;
1068 #ifdef G4MULTITHREADED
1071 return theDecayTable;
1077 if (Z < 1 || A < 2)
G4cout <<
"Z and A not valid!" <<
G4endl;
1079 std::ifstream DecaySchemeFile(filename);
1080 if (DecaySchemeFile) {
1081 G4int ID_ion = A*1000 + Z;
1084 G4cout <<
"The file " << filename <<
" does not exist!" <<
G4endl;
1091 G4int theG, std::vector<G4double> theRates,
1092 std::vector<G4double> theTaos)
1118 G4int nGeneration = 0;
1119 std::vector<G4double> rates;
1120 std::vector<G4double> taos;
1124 rates.push_back(-1.);
1127 G4int A = ((
const G4Ions*)(&theParentNucleus))->GetAtomicMass();
1128 G4int Z = ((
const G4Ions*)(&theParentNucleus))->GetAtomicNumber();
1129 G4double E = ((
const G4Ions*)(&theParentNucleus))->GetExcitationEnergy();
1131 if (tao < 0.) tao = 1e-100;
1132 taos.push_back(tao);
1164 std::vector<G4double> TP;
1165 std::vector<G4double> RP;
1175 const G4int nMode = 9;
1183 ed <<
" While count exceeded " <<
G4endl;
1192 for (j = nS; j < nT; j++) {
1200 G4cout <<
"G4RadioactiveDecay::AddDecayRateTable : daughters of ("
1201 << ZP <<
", " << AP <<
", " << EP
1202 <<
") are being calculated, generation = " << nGeneration
1206 aParentNucleus = theIonTable->
GetIon(ZP,AP,EP);
1213 for (
G4int k = 0; k < nMode; k++) brs[k] = 0.0;
1216 for (i = 0; i < aTempDecayTable->
entries(); i++) {
1218 theNuclearDecayChannel =
static_cast<G4NuclearDecay*
>(theChannel);
1223 AD = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicMass();
1224 ZD = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicNumber();
1236 theDecayTable->
Insert(theChannel);
1238 brs[theDecayMode] += theChannel->
GetBR();
1241 brs[theDecayMode] += theChannel->
GetBR();
1244 brs[theDecayMode] += theChannel->
GetBR();
1248 brs[2] = brs[2]+brs[3]+brs[4]+brs[5];
1249 brs[3] = brs[4] =brs[5] = 0.0;
1250 for (i= 0; i<nMode; i++){
1255 theITChannel =
new G4ITDecay(aParentNucleus, brs[0], 0.0, 0.0);
1257 theDecayTable->
Insert(theITChannel);
1264 theDecayTable->
Insert(theBetaMinusChannel);
1271 theDecayTable->
Insert(theBetaPlusChannel);
1278 theDecayTable->
Insert(theAlphaChannel);
1285 theDecayTable->
Insert(theProtonChannel);
1291 theDecayTable->
Insert(theNeutronChannel);
1301 for (i = 0; i < theDecayTable->
entries(); i++){
1303 theNuclearDecayChannel =
static_cast<G4NuclearDecay*
>(theChannel);
1304 theBR = theChannel->
GetBR();
1309 if (theNuclearDecayChannel->
GetDecayMode() ==
IT && nGeneration == 1) {
1311 A = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicMass();
1312 Z = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicNumber();
1313 theDaughterNucleus=theIonTable->
GetIon(Z,A,0.);
1316 aParentNucleus != theDaughterNucleus) {
1320 if (aTempDecayTable->
entries() ) {
1321 A = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicMass();
1322 Z = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicNumber();
1323 E = ((
const G4Ions*)(theDaughterNucleus))->GetExcitationEnergy();
1326 if (TaoPlus <= 0.) TaoPlus = 1e-100;
1336 taos.push_back(TaoPlus);
1342 long double ta1,ta2;
1343 ta2 = (
long double)TaoPlus;
1344 for (k = 0; k < RP.size(); k++){
1345 ta1 = (
long double)TP[k];
1349 theRate = ta1/(ta1-ta2);
1351 theRate = theRate * theBR * RP[k];
1352 rates.push_back(theRate);
1359 long double aRate, aRate1;
1361 for (k = 0; k < RP.size(); k++){
1362 ta1 = (
long double)TP[k];
1366 aRate = ta2/(ta1-ta2);
1368 aRate = aRate * (
long double)(theBR * RP[k]);
1372 rates.push_back(theRate);
1384 if (nS == nT) stable =
true;
1411 std::ifstream infile ( filename, std::ios::in );
1414 ed <<
" Could not open file " << filename <<
G4endl;
1415 G4Exception(
"G4RadioactiveDecay::SetSourceTimeProfile()",
"HAD_RDM_001",
1424 ed <<
" While count exceeded " <<
G4endl;
1426 while (infile >> bin >> flux ) {
1435 G4Exception(
"G4RadioactiveDecay::SetSourceTimeProfile()",
"HAD_RDM_002",
1462 std::ifstream infile(filename, std::ios::in);
1463 if (!infile)
G4Exception(
"G4RadioactiveDecay::SetDecayBias()",
"HAD_RDM_003",
1476 ed <<
" While count exceeded " <<
G4endl;
1478 while (infile >> bin >> flux ) {
1487 G4Exception(
"G4RadioactiveDecay::SetDecayBias()",
"HAD_RDM_004",
1534 G4cout <<
"G4RadioactiveDecay::DecayIt : "
1536 <<
" is not selected for the RDM"<<
G4endl;
1559 G4cerr <<
"G4RadioactiveDecay::DecayIt : "
1561 <<
" is not a valid nucleus for the RDM"<<
G4endl;
1574 if (theDecayTable == 0 || theDecayTable->
entries() == 0) {
1579 G4cerr <<
"G4RadioactiveDecay::DecayIt : decay table not defined for ";
1611 if ( products->
entries() == 1) {
1640 if (temptime < 0.) temptime = 0.;
1641 finalGlobalTime += temptime;
1642 finalLocalTime += temptime;
1645 products->
Boost(ParentEnergy, ParentDirection);
1652 G4cout <<
"G4RadioactiveDecay::DecayIt : Decay vertex :";
1653 G4cout <<
" Time: " <<finalGlobalTime/
ns <<
"[ns]";
1658 G4cout <<
"G4Decay::DecayIt : decay products in Lab. Frame" <<
G4endl;
1663 for (index=0; index < numberOfSecondaries; index++) {
1665 finalGlobalTime, currentPosition);
1677 G4cout <<
"DecayIt: Variance Reduction version " <<
G4endl;
1694 std::vector<G4double> PT;
1695 std::vector<G4double> PR;
1697 long double decayRate;
1701 G4int numberOfSecondaries;
1702 G4int totalNumberOfSecondaries = 0;
1706 std::vector<G4DynamicParticle*> secondaryparticles;
1707 std::vector<G4double> pw;
1708 std::vector<G4double> ptime;
1724 }
else if (nbin > 1) {
1749 for (j = 0; j < PT.size(); j++) {
1751 decayRate -= PR[j] * (
long double)taotime;
1773 parentNucleus = theIonTable->
GetIon(PZ,PA,PE);
1785 if (theDecayChannel == 0) {
1789 G4cerr <<
" G4RadioactiveDecay::DoIt : cannot determine decay channel ";
1790 G4cerr <<
" for this nucleus; decay as if no biasing active ";
1795 tempprods =
DoDecay(*parentNucleus);
1800 tempprods = theDecayChannel->DecayIt(tempmass);
1801 weight *= (theDecayChannel->GetBR())*(decayTable->
entries());
1804 tempprods =
DoDecay(*parentNucleus);
1808 numberOfSecondaries = tempprods->
entries();
1809 currentTime = finalGlobalTime + theDecayTime;
1810 for (index = 0; index < numberOfSecondaries; index++) {
1813 pw.push_back(weight);
1814 ptime.push_back(currentTime);
1815 secondaryparticles.push_back(asecondaryparticle);
1825 totalNumberOfSecondaries = pw.size();
1827 for (index=0; index < totalNumberOfSecondaries; index++) {
1829 ptime[index], currentPosition);
1871 if (theDecayChannel == 0) {
1873 G4cerr <<
"G4RadioactiveDecay::DoIt : can not determine decay channel";
1879 G4cerr <<
"G4RadioactiveDecay::DoIt : selected decay channel addr:";
1898 if (0 == products || 0 == products->
entries())
return;
1917 if (daughterType == electron || daughterType == positron ||
1918 daughterType == neutron || daughterType == gamma ||
1926 G4cout <<
"CollimateDecayProduct for daughter "
1951 dir.setPhi(dir.phi()+phi);
1952 dir.setTheta(dir.theta()+std::acos(cosTheta));
1957 G4cout <<
" ChooseCollimationDirection returns " << dir <<
G4endl;
G4double halflifethreshold
G4RadioactiveDecayRateVector theDecayRateTable
G4DecayProducts * DoDecay(const G4ParticleDefinition &theParticleDef)
void SetBR(G4double value)
static G4LossTableManager * Instance()
G4double GetLocalTime() const
void InitialiseAtomicDeexcitation()
void SelectAVolume(const G4String aVolume)
std::map< G4String, G4DecayTable * > DecayTableMap
std::ostringstream G4ExceptionDescription
G4double GetKineticEnergy() const
CLHEP::Hep3Vector G4ThreeVector
G4bool IsRateTableReady(const G4ParticleDefinition &)
const G4DynamicParticle * GetDynamicParticle() const
void SetHLThreshold(G4double HLT)
std::vector< G4String > ValidVolumes
void SetARM(G4bool onoff)
G4double HalfLife() const
void SetTaos(std::vector< G4double > value)
G4String strip(G4int strip_Type=trailing, char c=' ')
void SetDecayRateC(std::vector< G4double > value)
G4bool GetPDGStable() const
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
static G4Alpha * Definition()
const G4ThreeVector & GetPosition() const
void AddSecondary(G4Track *aSecondary)
G4TrackStatus GetTrackStatus() const
G4RadioactiveDecayMode GetDecayMode()
G4RadioactiveDecayRates theDecayRateVector
static G4Electron * Definition()
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4VDecayChannel * GetDecayChannel(G4int index) const
G4double GetMeanLifeTime(const G4Track &theTrack, G4ForceCondition *condition)
G4int GetVerboseLevel() const
void SetMomentumDirection(const G4ThreeVector &aDirection)
static G4NuclearLevelStore * GetInstance()
G4ParticleDefinition * GetDefinition() const
void SetSourceTimeProfile(G4String filename)
G4bool IsApplicable(const G4ParticleDefinition &)
void Boost(G4double totalEnergy, const G4ThreeVector &momentumDirection)
void SetGeneration(G4int value)
static G4Positron * Definition()
void ClearNumberOfInteractionLengthLeft()
#define G4MUTEX_INITIALIZER
const G4String & GetParticleName() const
void SetWeight(G4double aValue)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetItsRates(G4RadioactiveDecayRates arate)
G4ParticleChangeForRadDecay fParticleChangeForRadDecay
G4double GetTotalMomentum() const
static G4Proton * Definition()
virtual void Initialize(const G4Track &)
G4IonTable * GetIonTable() const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
void ProposeLocalTime(G4double t)
static const G4ThreeVector origin
void SetDecayRate(G4int, G4int, G4double, G4int, std::vector< G4double >, std::vector< G4double >)
const G4ThreeVector & GetMomentumDirection() const
void CollimateDecayProduct(G4DynamicParticle *product)
G4VDecayChannel * SelectADecayChannel(G4double parentMass=-1.)
static G4LogicalVolumeStore * GetInstance()
G4ThreeVector ChooseCollimationDirection() const
G4int GetDecayTimeBin(const G4double aDecayTime)
void SetProcessSubType(G4int)
void DeselectAllVolumes()
const G4String & GetParticleType() const
const G4ParticleDefinition * GetParticleDefinition() const
G4double GetGlobalTime() const
G4double GetTaoTime(const G4double, const G4double)
G4NucleusLimits theNucleusLimits
const G4TouchableHandle & GetTouchableHandle() const
G4ParticleDefinition * GetDaughterNucleus()
G4DecayTable * GetDecayTable(const G4ParticleDefinition *)
G4NuclearLevelManager * GetManager(G4int Z, G4int A)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void Insert(G4VDecayChannel *aChannel)
G4double GetDaughterExcitation()
void SetARM(G4bool onoff)
G4double GetMeanFreePath(const G4Track &theTrack, G4double previousStepSize, G4ForceCondition *condition)
G4RadioactiveDecayRate theDecayRate
static const G4double levelTolerance
G4RadioactiveDecayRateTable theDecayRateTableVector
std::map< G4int, G4String > theUserRadioactiveDataFiles
static const double nanosecond
G4LogicalVolume * GetLogicalVolume() const
G4double forceDecayHalfAngle
G4double GetPDGMass() const
static G4ParticleTable * GetParticleTable()
void GetDecayRateTable(const G4ParticleDefinition &)
G4RadioactiveDecaymessenger * theRadioactiveDecaymessenger
void SetNumberOfSecondaries(G4int totSecondaries)
const G4double x[NPOINTSGL]
G4DynamicParticle * PopProducts()
G4VParticleChange * pParticleChange
void AddDecayRateTable(const G4ParticleDefinition &)
G4DecayTable * LoadDecayTable(const G4ParticleDefinition &theParentNucleus)
static G4Neutron * Definition()
G4int NumberOfLevels() const
G4VPhysicalVolume * GetVolume() const
std::vector< G4RadioactivityTable * > theRadioactivityTables
G4double GetWeight() const
void SetIonName(G4String name)
G4double GetPDGLifeTime() const
G4RadioactiveDecay(const G4String &processName="RadioactiveDecay")
G4ThreeVector forceDecayDirection
G4VAtomDeexcitation * AtomDeexcitation()
virtual G4DecayProducts * DecayIt(G4double parentMass=-1.0)=0
const G4String & GetName() const
void ProposeTrackStatus(G4TrackStatus status)
void BuildPhysicsTable(const G4ParticleDefinition &)
void SetAnalogueMonteCarlo(G4bool r)
static const G4double alpha
void DeselectAVolume(const G4String aVolume)
void SetE(G4double value)
void SetAtomDeexcitation(G4VAtomDeexcitation *)
const G4NuclearLevel * NearestLevel(G4double energy, G4double eDiffMax=1.e+8) const
void AddUserDecayDataFile(G4int Z, G4int A, G4String filename)
void CollimateDecay(G4DecayProducts *products)
void SetDecayBias(G4String filename)
static G4Gamma * Definition()
void SetGoodForTrackingFlag(G4bool value=true)
G4VParticleChange * DecayIt(const G4Track &theTrack, const G4Step &theStep)
G4GLOB_DLL std::ostream G4cerr
G4int GetBaryonNumber() const