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;
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;
876 theDecayTable->
Insert(aBetaMinusChannel);
885 if (modeFirstRecord[2]) {
886 modeFirstRecord[2] =
false;
894 theDecayTable->
Insert(aBetaPlusChannel);
902 if (modeFirstRecord[3]) {
903 modeFirstRecord[3] =
false;
911 theDecayTable->
Insert(aKECChannel);
918 if (modeFirstRecord[4]) {
919 modeFirstRecord[4] =
false;
927 theDecayTable->
Insert(aLECChannel);
934 if (modeFirstRecord[5]) {
935 modeFirstRecord[5] =
false;
943 theDecayTable->
Insert(aMECChannel);
949 if (modeFirstRecord[6]) {
950 modeFirstRecord[6] =
false;
957 theDecayTable->
Insert(anAlphaChannel);
963 if (modeFirstRecord[7]) {
964 modeFirstRecord[7] =
false;
971 theDecayTable->
Insert(aProtonChannel);
977 if (modeFirstRecord[8]) {
978 modeFirstRecord[8] =
false;
985 theDecayTable->
Insert(aNeutronChannel);
1020 G4Exception(
"G4RadioactiveDecay::LoadDecayTable()",
"HAD_RDM_000",
1038 theNuclearDecayChannel =
static_cast<G4NuclearDecay*
>(theChannel);
1041 if (theDecayMode !=
IT) {
1042 theBR = theChannel->
GetBR();
1043 theChannel->
SetBR(theBR*modeTotalBR[theDecayMode]/modeSumBR[theDecayMode]);
1047 DecaySchemeFile.close();
1049 if (!found && levelEnergy > 0) {
1055 theDecayTable->
Insert(anITChannel);
1057 if (!theDecayTable) {
1060 G4cerr <<
"G4RadoactiveDecay::LoadDecayTable() : cannot find ion radioactive decay file "
1063 return theDecayTable;
1070 #ifdef G4MULTITHREADED
1073 return theDecayTable;
1079 if (Z < 1 || A < 2)
G4cout <<
"Z and A not valid!" <<
G4endl;
1081 std::ifstream DecaySchemeFile(filename);
1082 if (DecaySchemeFile) {
1083 G4int ID_ion = A*1000 + Z;
1086 G4cout <<
"The file " << filename <<
" does not exist!" <<
G4endl;
1093 G4int theG, std::vector<G4double> theRates,
1094 std::vector<G4double> theTaos)
1120 G4int nGeneration = 0;
1121 std::vector<G4double> rates;
1122 std::vector<G4double> taos;
1126 rates.push_back(-1.);
1129 G4int A = ((
const G4Ions*)(&theParentNucleus))->GetAtomicMass();
1130 G4int Z = ((
const G4Ions*)(&theParentNucleus))->GetAtomicNumber();
1131 G4double E = ((
const G4Ions*)(&theParentNucleus))->GetExcitationEnergy();
1133 if (tao < 0.) tao = 1e-100;
1134 taos.push_back(tao);
1166 std::vector<G4double> TP;
1167 std::vector<G4double> RP;
1177 const G4int nMode = 9;
1185 ed <<
" While count exceeded " <<
G4endl;
1195 for (j = nS; j < nT; j++) {
1203 G4cout <<
"G4RadioactiveDecay::AddDecayRateTable : daughters of ("
1204 << ZP <<
", " << AP <<
", " << EP
1205 <<
") are being calculated, generation = " << nGeneration
1209 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);
1302 for (i = 0; i < theDecayTable->
entries(); i++){
1304 theNuclearDecayChannel =
static_cast<G4NuclearDecay*
>(theChannel);
1305 theBR = theChannel->
GetBR();
1310 if (theNuclearDecayChannel->
GetDecayMode() ==
IT && nGeneration == 1) {
1312 A = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicMass();
1313 Z = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicNumber();
1314 theDaughterNucleus=theIonTable->
GetIon(Z,A,0.);
1317 aParentNucleus != theDaughterNucleus) {
1321 if (aTempDecayTable->
entries() ) {
1322 A = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicMass();
1323 Z = ((
const G4Ions*)(theDaughterNucleus))->GetAtomicNumber();
1324 E = ((
const G4Ions*)(theDaughterNucleus))->GetExcitationEnergy();
1327 if (TaoPlus <= 0.) TaoPlus = 1e-100;
1337 taos.push_back(TaoPlus);
1343 long double ta1,ta2;
1344 ta2 = (
long double)TaoPlus;
1345 for (k = 0; k < RP.size(); k++){
1346 ta1 = (
long double)TP[k];
1350 theRate = ta1/(ta1-ta2);
1352 theRate = theRate * theBR * RP[k];
1353 rates.push_back(theRate);
1360 long double aRate, aRate1;
1362 for (k = 0; k < RP.size(); k++){
1363 ta1 = (
long double)TP[k];
1367 aRate = ta2/(ta1-ta2);
1369 aRate = aRate * (
long double)(theBR * RP[k]);
1373 rates.push_back(theRate);
1385 if (nS == nT) stable =
true;
1413 std::ifstream infile ( filename, std::ios::in );
1416 ed <<
" Could not open file " << filename <<
G4endl;
1417 G4Exception(
"G4RadioactiveDecay::SetSourceTimeProfile()",
"HAD_RDM_001",
1426 ed <<
" While count exceeded " <<
G4endl;
1428 while (infile >> bin >> flux ) {
1437 G4Exception(
"G4RadioactiveDecay::SetSourceTimeProfile()",
"HAD_RDM_002",
1464 std::ifstream infile(filename, std::ios::in);
1465 if (!infile)
G4Exception(
"G4RadioactiveDecay::SetDecayBias()",
"HAD_RDM_003",
1478 ed <<
" While count exceeded " <<
G4endl;
1480 while (infile >> bin >> flux ) {
1489 G4Exception(
"G4RadioactiveDecay::SetDecayBias()",
"HAD_RDM_004",
1536 G4cout <<
"G4RadioactiveDecay::DecayIt : "
1538 <<
" is not selected for the RDM"<<
G4endl;
1561 G4cerr <<
"G4RadioactiveDecay::DecayIt : "
1563 <<
" is not a valid nucleus for the RDM"<<
G4endl;
1577 if (theDecayTable == 0 || theDecayTable->
entries() == 0) {
1582 G4cerr <<
"G4RadioactiveDecay::DecayIt : decay table not defined for ";
1614 if ( products->
entries() == 1) {
1643 if (temptime < 0.) temptime = 0.;
1644 finalGlobalTime += temptime;
1645 finalLocalTime += temptime;
1648 products->
Boost(ParentEnergy, ParentDirection);
1655 G4cout <<
"G4RadioactiveDecay::DecayIt : Decay vertex :";
1656 G4cout <<
" Time: " <<finalGlobalTime/
ns <<
"[ns]";
1661 G4cout <<
"G4Decay::DecayIt : decay products in Lab. Frame" <<
G4endl;
1666 for (index=0; index < numberOfSecondaries; index++) {
1668 finalGlobalTime, currentPosition);
1680 G4cout <<
"DecayIt: Variance Reduction version " <<
G4endl;
1697 std::vector<G4double> PT;
1698 std::vector<G4double> PR;
1700 long double decayRate;
1704 G4int numberOfSecondaries;
1705 G4int totalNumberOfSecondaries = 0;
1709 std::vector<G4DynamicParticle*> secondaryparticles;
1710 std::vector<G4double> pw;
1711 std::vector<G4double> ptime;
1727 }
else if (nbin > 1) {
1752 for (j = 0; j < PT.size(); j++) {
1754 decayRate -= PR[j] * (
long double)taotime;
1776 parentNucleus = theIonTable->
GetIon(PZ,PA,PE);
1788 if (theDecayChannel == 0) {
1792 G4cerr <<
" G4RadioactiveDecay::DoIt : cannot determine decay channel ";
1793 G4cerr <<
" for this nucleus; decay as if no biasing active ";
1798 tempprods =
DoDecay(*parentNucleus);
1803 tempprods = theDecayChannel->DecayIt(tempmass);
1804 weight *= (theDecayChannel->GetBR())*(decayTable->
entries());
1807 tempprods =
DoDecay(*parentNucleus);
1811 numberOfSecondaries = tempprods->
entries();
1812 currentTime = finalGlobalTime + theDecayTime;
1813 for (index = 0; index < numberOfSecondaries; index++) {
1816 pw.push_back(weight);
1817 ptime.push_back(currentTime);
1818 secondaryparticles.push_back(asecondaryparticle);
1828 totalNumberOfSecondaries = pw.size();
1830 for (index=0; index < totalNumberOfSecondaries; index++) {
1832 ptime[index], currentPosition);
1874 if (theDecayChannel == 0) {
1876 G4cerr <<
"G4RadioactiveDecay::DoIt : can not determine decay channel";
1882 G4cerr <<
"G4RadioactiveDecay::DoIt : selected decay channel addr:";
1901 if (0 == products || 0 == products->
entries())
return;
1920 if (daughterType == electron || daughterType == positron ||
1921 daughterType == neutron || daughterType == gamma ||
1929 G4cout <<
"CollimateDecayProduct for daughter "
1954 dir.setPhi(dir.phi()+phi);
1955 dir.setTheta(dir.theta()+std::acos(cosTheta));
1960 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