00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "G4IonTable.hh"
00048 #include "G4PhysicalConstants.hh"
00049 #include "G4SystemOfUnits.hh"
00050 #include "G4ParticleTable.hh"
00051 #include "G4StateManager.hh"
00052 #include "G4Ions.hh"
00053 #include "G4UImanager.hh"
00054 #include "G4NucleiProperties.hh"
00055 #include "G4HyperNucleiProperties.hh"
00056
00057 #include "G4IsotopeProperty.hh"
00058 #include "G4VIsotopeTable.hh"
00059
00060 #include "G4ios.hh"
00061 #include <iostream>
00062 #include <iomanip>
00063
00064 #include <sstream>
00065
00066
00068 G4IonTable::G4IonTable()
00069 {
00070 fIonList = new G4IonList();
00071 fIsotopeTableList = new std::vector<G4VIsotopeTable*>;
00072 }
00073
00075 G4IonTable::~G4IonTable()
00076 {
00077
00078 if (fIsotopeTableList != 0) {
00079 for (size_t i = 0; i< fIsotopeTableList->size(); ++i) {
00080 G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i];
00081 delete fIsotopeTable;
00082 }
00083 fIsotopeTableList->clear();
00084 delete fIsotopeTableList;
00085 }
00086 fIsotopeTableList =0;
00087
00088
00089 if (fIonList ==0) return;
00090
00091
00092 fIonList->clear();
00093
00094 delete fIonList;
00095 fIonList =0;
00096 }
00097
00098
00100
00102 G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A,
00103 G4double E, G4int J)
00104 {
00105 G4ParticleDefinition* ion=0;
00106
00107
00108
00109 G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
00110 if (currentState == G4State_PreInit){
00111 #ifdef G4VERBOSE
00112 if (GetVerboseLevel()>1) {
00113 G4cerr << "G4IonTable::CreateIon() : can not create ion of "
00114 << " Z =" << Z << " A = " << A
00115 << " because the current state is PreInit !!" << G4endl;
00116 }
00117 #endif
00118 G4Exception( "G4IonTable::CreateIon()","PART105",
00119 JustWarning, "Can not create ions in PreInit state");
00120 return 0;
00121 }
00122
00123
00124 G4String name = GetIonName(Z, A, E);
00125 if ( name(0) == '?') {
00126 #ifdef G4VERBOSE
00127 if (GetVerboseLevel()>0) {
00128 G4cerr << "G4IonTable::CreateIon() : can not create ions "
00129 << " Z =" << Z << " A = " << A << G4endl;
00130 }
00131 #endif
00132 return 0;
00133 }
00134
00135 G4double life = -1.0;
00136 G4DecayTable* decayTable =0;
00137 G4bool stable = true;
00138 G4double mu = 0.0;
00139
00140 const G4IsotopeProperty* fProperty = FindIsotope(Z, A, E, J);
00141 if (fProperty !=0 ){
00142 E = fProperty->GetEnergy();
00143 J = fProperty->GetiSpin();
00144 life = fProperty->GetLifeTime();
00145 mu = fProperty->GetMagneticMoment();
00146 decayTable = fProperty->GetDecayTable();
00147 }
00148 stable = life <= 0.;
00149 G4double mass = GetNucleusMass(Z, A)+ E;
00150 G4double charge = G4double(Z)*eplus;
00151
00152 G4int encoding = GetNucleusEncoding(Z,A,E,J);
00153
00154
00155
00156
00157 ion = new G4Ions( name, mass, 0.0*MeV, charge,
00158 J, +1, 0,
00159 0, 0, 0,
00160 "nucleus", 0, A, encoding,
00161 stable, life, decayTable, false,
00162 "generic", 0,
00163 E );
00164 ion->SetPDGMagneticMoment(mu);
00165
00166
00167 ion->SetAntiPDGEncoding(0);
00168
00169 #ifdef G4VERBOSE
00170 if (GetVerboseLevel()>1) {
00171 G4cout << "G4IonTable::CreateIon() : create ion of " << name
00172 << " " << Z << ", " << A
00173 << " encoding=" << encoding << G4endl;
00174 }
00175 #endif
00176
00177
00178 AddProcessManager(name);
00179
00180 return ion;
00181 }
00182
00183
00185 G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, G4int L,
00186 G4double E, G4int J)
00187 {
00188 if (L==0) return CreateIon(A,Z,E,J);
00189
00190
00191 G4ParticleDefinition* ion=0;
00192
00193
00194
00195 G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
00196 if (currentState == G4State_PreInit){
00197 #ifdef G4VERBOSE
00198 if (GetVerboseLevel()>1) {
00199 G4cerr << "G4IonTable::CreateIon() : can not create ion of "
00200 << " Z =" << Z << " A = " << A << " L = " <<L
00201 << " because the current state is PreInit !!" << G4endl;
00202 }
00203 #endif
00204 G4Exception( "G4IonTable::CreateIon()","PART105",
00205 JustWarning, "Can not create ions in PreInit state");
00206 return 0;
00207 }
00208
00209
00210 G4String name = GetIonName(Z, A, L, E);
00211 if ( name(L) == '?') {
00212 #ifdef G4VERBOSE
00213 if (GetVerboseLevel()>0) {
00214 G4cerr << "G4IonTable::CreateIon() : can not create ions "
00215 << " Z =" << Z << " A = " << A << " L = " << L << G4endl;
00216 }
00217 #endif
00218 return 0;
00219 }
00220
00221 G4double life = -1.0;
00222 G4DecayTable* decayTable =0;
00223 G4bool stable = true;
00224 G4double mu = 0.0;
00225 G4double mass = GetNucleusMass(Z, A, L)+ E;
00226 G4double charge = G4double(Z)*eplus;
00227
00228 G4int encoding = GetNucleusEncoding(Z,A,L,E,J);
00229
00230
00231
00232
00233 ion = new G4Ions( name, mass, 0.0*MeV, charge,
00234 J, +1, 0,
00235 0, 0, 0,
00236 "nucleus", 0, A, encoding,
00237 stable, life, decayTable, false,
00238 "generic", 0,
00239 E );
00240 ion->SetPDGMagneticMoment(mu);
00241
00242
00243 ion->SetAntiPDGEncoding(0);
00244
00245 #ifdef G4VERBOSE
00246 if (GetVerboseLevel()>1) {
00247 G4cout << "G4IonTable::CreateIon() : create hyper ion of " << name
00248 << " encoding=" << encoding << G4endl;
00249 }
00250 #endif
00251
00252
00253 AddProcessManager(name);
00254
00255 return ion;
00256 }
00257
00259
00261 G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int , G4int )
00262 {
00263 return GetIon(Z, A);
00264 }
00265
00267 G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int J)
00268 {
00269 return GetIon( Z, A, 0.0, J);
00270 }
00271
00273 G4ParticleDefinition* G4IonTable::GetIon(G4int encoding)
00274 {
00275 G4int Z, A, L, J;
00276 G4double E;
00277 if (!GetNucleusByEncoding(encoding,Z,A,L,E,J) ){
00278 #ifdef G4VERBOSE
00279 if (GetVerboseLevel()>0) {
00280 G4cerr << "G4IonTable::GetIon() : illegal encoding"
00281 << " CODE:" << encoding << G4endl;
00282 }
00283 #endif
00284 G4Exception( "G4IonTable::GetIon()","PART106",
00285 JustWarning, "illegal encoding for an ion");
00286 return 0;
00287 }
00288
00289 return GetIon( Z, A, L, 0.0, J);
00290 }
00291
00293 G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4double E, G4int J)
00294 {
00295 if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) {
00296 #ifdef G4VERBOSE
00297 if (GetVerboseLevel()>0) {
00298 G4cerr << "G4IonTable::GetIon() : illegal atomic number/mass"
00299 << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl;
00300 }
00301 #endif
00302 return 0;
00303 }
00304
00305
00306 G4ParticleDefinition* ion = FindIon(Z,A,E,J);
00307
00308
00309 if (ion == 0) {
00310 ion = CreateIon(Z, A, E, J);
00311 }
00312
00313 return ion;
00314 }
00315
00317 G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int L, G4double E, G4int J)
00318 {
00319 if (L==0) return GetIon(Z,A,E,J);
00320
00321 if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) {
00322 #ifdef G4VERBOSE
00323 if (GetVerboseLevel()>0) {
00324 G4cerr << "G4IonTable::GetIon() : illegal atomic number/mass"
00325 << " Z =" << Z << " A = " << A << " L = " << L
00326 <<" E = " << E/keV << G4endl;
00327 }
00328 #endif
00329 return 0;
00330 } else if( A==2 ) {
00331 #ifdef G4VERBOSE
00332 if (GetVerboseLevel()>0) {
00333 G4cerr << "G4IonTable::GetIon() : No boud state for "
00334 << " Z =" << Z << " A = " << A << " L = " << L
00335 << " E = " << E/keV << G4endl;
00336 }
00337 #endif
00338 return 0;
00339 }
00340
00341
00342 G4ParticleDefinition* ion = FindIon(Z,A,L,E,J);
00343
00344
00345 if (ion == 0) {
00346 ion = CreateIon(Z, A, L, E, J);
00347 }
00348
00349 return ion;
00350 }
00351
00353 G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4double E, G4int J)
00354 {
00355 const G4double EnergyTorelance = 0.1 * keV;
00356
00357 if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) {
00358 #ifdef G4VERBOSE
00359 if (GetVerboseLevel()>0) {
00360 G4cerr << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level "
00361 << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl;
00362 }
00363 #endif
00364 G4Exception( "G4IonTable::FindIon()","PART107",
00365 JustWarning, "illegal atomic number/mass");
00366 return 0;
00367 }
00368
00369
00370 const G4ParticleDefinition* ion=0;
00371 G4bool isFound = false;
00372
00373
00374 G4int encoding=GetNucleusEncoding(Z, A, 0);
00375 G4IonList::iterator i = fIonList->find(encoding);
00376 for( ;i != fIonList->end() ; i++) {
00377 ion = i->second;
00378 if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break;
00379
00380
00381 G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy();
00382 if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) {
00383 isFound = true;
00384 break;
00385 }
00386 }
00387
00388 if ( isFound ){
00389 return const_cast<G4ParticleDefinition*>(ion);
00390 } else {
00391 return 0;
00392 }
00393 }
00394
00395
00397 G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4int L, G4double E, G4int J)
00398 {
00399 if (L==0) return FindIon(Z,A,E,J);
00400
00401 const G4double EnergyTorelance = 0.1 * keV;
00402
00403 if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) {
00404 #ifdef G4VERBOSE
00405 if (GetVerboseLevel()>0) {
00406 G4cerr << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level "
00407 << " Z =" << Z << " A = " << A << " L = " << L
00408 <<" E = " << E/keV << G4endl;
00409 }
00410 #endif
00411 G4Exception( "G4IonTable::FindIon()","PART107",
00412 JustWarning, "illegal atomic number/mass");
00413 return 0;
00414 }
00415
00416
00417 const G4ParticleDefinition* ion=0;
00418 G4bool isFound = false;
00419
00420
00421 G4int encoding=GetNucleusEncoding(Z, A, L);
00422 G4IonList::iterator i = fIonList->find(encoding);
00423 for( ;i != fIonList->end() ; i++) {
00424 ion = i->second;
00425 if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break;
00426 if( ion->GetQuarkContent(3) != L) break;
00427
00428
00429 G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy();
00430
00431 if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) {
00432 isFound = true;
00433 break;
00434 }
00435 }
00436
00437 if ( isFound ){
00438 return const_cast<G4ParticleDefinition*>(ion);
00439 } else {
00440 return 0;
00441 }
00442 }
00443
00444
00446 G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4double E, G4int )
00447 {
00448
00449
00450
00451
00452
00453
00454
00456 const G4double EnergyTorelance = 0.1 * keV;
00457 if ( Z==1 && A==1 && E< EnergyTorelance ) {
00458
00459 return 2212;
00460 }
00461
00462 G4int encoding = 1000000000;
00463 encoding += Z * 10000;
00464 encoding += A *10;
00465 if (E>0.0) encoding += 1;
00466
00467 return encoding;
00468 }
00469
00471 G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4int L,
00472 G4double E, G4int )
00473 {
00474
00475
00476
00477
00478
00479
00480
00481
00483
00484 G4int encoding = 1000000000;
00485 encoding += L* 10000000;
00486 encoding += Z * 10000;
00487 encoding += A *10;
00488 if (E>0.0) encoding += 1;
00489
00490 return encoding;
00491 }
00492
00494 G4bool G4IonTable::GetNucleusByEncoding(G4int encoding,
00495 G4int &Z, G4int &A,
00496 G4double &E, G4int &J)
00497 {
00498 if (encoding <= 0) {
00499
00500 return false;
00501 }
00502 if (encoding == 2212) {
00503
00504 Z = 1;
00505 A = 1;
00506 E=0.0;
00507 J=0;
00508 return true;
00509 }
00510
00511 if (encoding % 10 != 0) {
00513 return false;
00514 }
00515
00516 encoding -= 1000000000;
00517 Z = encoding/10000;
00518 encoding -= 10000*Z;
00519 A = encoding/10;
00520
00521 E=0.0;
00522 J=0;
00523
00524 return true;
00525 }
00527 G4bool G4IonTable::GetNucleusByEncoding(G4int encoding,
00528 G4int &Z, G4int &A,
00529 G4int &L,
00530 G4double &E, G4int &J)
00531 {
00532 if (encoding <= 0) {
00533
00534 return false;
00535 }
00536 if (encoding % 10 != 0) {
00538 return false;
00539 }
00540 if (encoding < 1000000000) {
00541
00542 return false;
00543 }
00544
00545 encoding -= 1000000000;
00546 L = encoding/10000000;
00547 encoding -= 10000000*L;
00548 Z = encoding/10000;
00549 encoding -= 10000*Z;
00550 A = encoding/10;
00551
00552 E=0.0;
00553 J=0;
00554
00555 return true;
00556 }
00558 const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4double E) const
00559 {
00560 static G4String name;
00561 name ="";
00562 if ( (0< Z) && (Z <=numberOfElements) ) {
00563 name = elementName[Z-1];
00564 } else if (Z > numberOfElements) {
00565 std::ostringstream os1;
00566 os1.setf(std::ios::fixed);
00567 os1 << Z ;
00568 name = "E" + os1.str() + "-";
00569 } else {
00570 name = "?";
00571 return name;
00572 }
00573 std::ostringstream os;
00574 os.setf(std::ios::fixed);
00575 os << A << '[' << std::setprecision(1) << E/keV << ']';
00576 name += os.str();
00577 return name;
00578 }
00579
00581 const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4int L, G4double E) const
00582 {
00583 if (L==0) return GetIonName(Z, A, E);
00584 static G4String name;
00585 name ="";
00586 for (int i =0; i<L; i++){
00587 name +="L";
00588 }
00589 name += GetIonName(Z, A, E);
00590 return name;
00591 }
00592
00594 G4bool G4IonTable::IsIon(const G4ParticleDefinition* particle)
00595 {
00596
00597
00598 static G4String nucleus("nucleus");
00599 static G4String proton("proton");
00600
00601
00602 if ((particle->GetAtomicMass()>0) &&
00603 (particle->GetAtomicNumber()>0) ){
00604 if (particle->GetBaryonNumber()>0) return true;
00605 else return false;
00606 }
00607
00608
00609
00610 if (particle->GetParticleType() == nucleus) return true;
00611
00612
00613 if (particle->GetParticleName() == proton) return true;
00614
00615 return false;
00616 }
00617
00619 G4bool G4IonTable::IsAntiIon(const G4ParticleDefinition* particle)
00620 {
00621
00622
00623 static G4String anti_nucleus("anti_nucleus");
00624 static G4String anti_proton("anti_proton");
00625
00626
00627 if ((particle->GetAtomicMass()>0) &&
00628 (particle->GetAtomicNumber()>0) ){
00629 if (particle->GetBaryonNumber()<0) return true;
00630 else return false;
00631 }
00632
00633
00634 if (particle->GetParticleType() == anti_nucleus) return true;
00635
00636
00637 if (particle->GetParticleName() == anti_proton) return true;
00638
00639 return false;
00640 }
00641
00643 #include <algorithm>
00644
00645 G4bool G4IonTable::IsLightIon(const G4ParticleDefinition* particle) const
00646 {
00647 static const std::string names[] = { "proton", "alpha", "deuteron",
00648 "triton", "He3"};
00649
00650
00651 return std::find(names, names+5, particle->GetParticleName())!=names+5;
00652 }
00653
00654 G4bool G4IonTable::IsLightAntiIon(const G4ParticleDefinition* particle) const
00655 {
00656 static const std::string names[] = { "anti_proton", "anti_alpha", "anti_deuteron",
00657 "anti_triton", "anti_He3"};
00658
00659
00660 return std::find(names, names+5, particle->GetParticleName())!=names+5;
00661 }
00662
00664 G4ParticleDefinition* G4IonTable::GetLightIon(G4int Z, G4int A) const
00665 {
00666
00667 static G4bool isInitialized = false;
00668 static const G4ParticleDefinition* p_proton=0;
00669 static const G4ParticleDefinition* p_deuteron=0;
00670 static const G4ParticleDefinition* p_triton=0;
00671 static const G4ParticleDefinition* p_alpha=0;
00672 static const G4ParticleDefinition* p_He3=0;
00673
00674 if (!isInitialized) {
00675 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("proton");
00676 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron");
00677 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("triton");
00678 p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("alpha");
00679 p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("He3");
00680 isInitialized = true;
00681 }
00682
00683 const G4ParticleDefinition* ion=0;
00684 if ( (Z<=2) ) {
00685 if ( (Z==1)&&(A==1) ) {
00686 ion = p_proton;
00687 } else if ( (Z==1)&&(A==2) ) {
00688 ion = p_deuteron;
00689 } else if ( (Z==1)&&(A==3) ) {
00690 ion = p_triton;
00691 } else if ( (Z==2)&&(A==4) ) {
00692 ion = p_alpha;
00693 } else if ( (Z==2)&&(A==3) ) {
00694 ion = p_He3;
00695 }
00696 }
00697 return const_cast<G4ParticleDefinition*>(ion);
00698 }
00699
00701 G4ParticleDefinition* G4IonTable::GetLightAntiIon(G4int Z, G4int A) const
00702 {
00703
00704 static G4bool isInitialized = false;
00705 static const G4ParticleDefinition* p_proton=0;
00706 static const G4ParticleDefinition* p_deuteron=0;
00707 static const G4ParticleDefinition* p_triton=0;
00708 static const G4ParticleDefinition* p_alpha=0;
00709 static const G4ParticleDefinition* p_He3=0;
00710
00711 if (!isInitialized) {
00712 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("anti_proton");
00713 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("anti_deuteron");
00714 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("anti_triton");
00715 p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("anti_alpha");
00716 p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("anti_He3");
00717 isInitialized = true;
00718 }
00719
00720 const G4ParticleDefinition* ion=0;
00721 if ( (Z<=2) ) {
00722 if ( (Z==1)&&(A==1) ) {
00723 ion = p_proton;
00724 } else if ( (Z==1)&&(A==2) ) {
00725 ion = p_deuteron;
00726 } else if ( (Z==1)&&(A==3) ) {
00727 ion = p_triton;
00728 } else if ( (Z==2)&&(A==4) ) {
00729 ion = p_alpha;
00730 } else if ( (Z==2)&&(A==3) ) {
00731 ion = p_He3;
00732 }
00733 }
00734 return const_cast<G4ParticleDefinition*>(ion);
00735 }
00736
00737
00739
00741 G4double G4IonTable::GetNucleusMass(G4int Z, G4int A, G4int L) const
00742 {
00743 if ( (A<1) || (Z<0) || (L<0) ){
00744 #ifdef G4VERBOSE
00745 if (GetVerboseLevel()>0) {
00746 G4cerr << "G4IonTable::GetNucleusMass() : illegal atomic number/mass "
00747 << " Z =" << Z << " A = " << A << G4endl;
00748 }
00749 #endif
00750 G4Exception( "G4IonTable::GetNucleusMass()","PART107",
00751 EventMustBeAborted, "illegal atomic number/mass");
00752 return -1.0;
00753 }
00754
00755 G4double mass;
00756 if (L == 0) {
00757
00758 const G4ParticleDefinition* ion=GetLightIon(Z, A);
00759
00760 if (ion!=0) {
00761 mass = ion->GetPDGMass();
00762 } else {
00763
00764 mass = G4NucleiProperties::GetNuclearMass(A, Z);
00765 }
00766
00767 } else {
00768 mass = G4HyperNucleiProperties::GetNuclearMass(A, Z, L);
00769 }
00770 return mass;
00771 }
00772
00774 G4double G4IonTable::GetIonMass(G4int Z, G4int A, G4int L) const
00775 {
00776 return GetNucleusMass(Z,A,L);
00777 }
00778
00779
00781
00783
00784 void G4IonTable::clear()
00785 {
00786 if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
00787 G4Exception("G4IonTable::clear()",
00788 "PART116", JustWarning,
00789 "No effects because readyToUse is true.");
00790 return;
00791 }
00792
00793 #ifdef G4VERBOSE
00794 if (GetVerboseLevel()>2) {
00795 G4cout << "G4IonTable::Clear() : number of Ion regsitered = ";
00796 G4cout << fIonList->size() << G4endl;
00797 }
00798 #endif
00799 fIonList->clear();
00800 }
00801
00802 void G4IonTable::Insert(const G4ParticleDefinition* particle)
00803 {
00804 if (!IsIon(particle)) return;
00805 if (Contains(particle)) return;
00806
00807 G4int Z = particle->GetAtomicNumber();
00808 G4int A = particle->GetAtomicMass();
00809 G4int L = particle->GetQuarkContent(3);
00810 G4int encoding=GetNucleusEncoding(Z, A, L);
00811
00812 fIonList->insert( std::pair<const G4int, const G4ParticleDefinition*>(encoding, particle) );
00813
00814 }
00815
00817 void G4IonTable::Remove(const G4ParticleDefinition* particle)
00818 {
00819 if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
00820 G4StateManager* pStateManager = G4StateManager::GetStateManager();
00821 G4ApplicationState currentState = pStateManager->GetCurrentState();
00822 if (currentState != G4State_PreInit) {
00823 G4String msg = "Request of removing ";
00824 msg += particle->GetParticleName();
00825 msg += " has No effects other than Pre_Init";
00826 G4Exception("G4IonTable::Remove()",
00827 "PART117", JustWarning, msg);
00828 return;
00829 } else {
00830 #ifdef G4VERBOSE
00831 if (GetVerboseLevel()>0){
00832 G4cout << particle->GetParticleName()
00833 << " will be removed from the IonTable " << G4endl;
00834 }
00835 #endif
00836 }
00837 }
00838
00839 if (IsIon(particle)) {
00840 G4int Z = particle->GetAtomicNumber();
00841 G4int A = particle->GetAtomicMass();
00842 G4int L = particle->GetQuarkContent(3);
00843 G4int encoding=GetNucleusEncoding(Z, A, L);
00844 if (encoding !=0 ) {
00845 G4IonList::iterator i = fIonList->find(encoding);
00846 for( ;i != fIonList->end() ; i++) {
00847 if (particle == i->second) {
00848 fIonList->erase(i);
00849 break;
00850 }
00851 }
00852 }
00853 } else {
00854 #ifdef G4VERBOSE
00855 if (GetVerboseLevel()>1) {
00856 G4cerr << "G4IonTable::Remove :" << particle->GetParticleName()
00857 << " is not ions" << G4endl;
00858 }
00859 #endif
00860 }
00861
00862 }
00863
00864
00865
00867
00869 void G4IonTable::DumpTable(const G4String &particle_name) const
00870 {
00871 const G4ParticleDefinition* ion;
00872 G4IonList::iterator idx;
00873 for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) {
00874 ion = idx->second;
00875 if (( particle_name == "ALL" ) || (particle_name == "all")){
00876 ion->DumpTable();
00877 } else if ( particle_name == ion->GetParticleName() ) {
00878 ion->DumpTable();
00879 }
00880 }
00881 }
00882
00884 const G4String G4IonTable::elementName[] = {
00885 "H", "He",
00886 "Li", "Be", "B", "C", "N", "O", "F", "Ne",
00887 "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar",
00888 "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr",
00889 "Rb", "Sr", "Y", "Zr", "Nb", "Mo","Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe",
00890 "Cs", "Ba",
00891 "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu",
00892 "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn",
00893 "Fr", "Ra",
00894 "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr",
00895 "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg",
00896 "Uub", "Uut", "Uuq","Uup","Uuh","Uus","Uuo"
00897 };
00898
00899
00901 G4int G4IonTable::GetVerboseLevel() const
00902 {
00903 return G4ParticleTable::GetParticleTable()->GetVerboseLevel();
00904 }
00905
00907 void G4IonTable::AddProcessManager(const G4String& name)
00908 {
00909
00910 std::ostringstream osAdd;
00911 osAdd << "/run/particle/addProcManager "<< name;
00912 G4String cmdAdd = osAdd.str();
00913
00914
00915 G4int tempVerboseLevel = G4UImanager::GetUIpointer()->GetVerboseLevel();
00916 G4UImanager::GetUIpointer()->SetVerboseLevel(0);
00917
00918
00919 G4UImanager::GetUIpointer()->ApplyCommand(cmdAdd);
00920
00921
00922 G4UImanager::GetUIpointer()->SetVerboseLevel(tempVerboseLevel);
00923 }
00924
00925 #include <vector>
00926
00928 void G4IonTable::RegisterIsotopeTable(G4VIsotopeTable* table)
00929 {
00930 fIsotopeTableList->push_back(table);
00931 }
00932
00934 G4VIsotopeTable* G4IonTable::GetIsotopeTable(size_t index) const
00935 {
00936 G4VIsotopeTable* fIsotopeTable=0;
00937 if ( index < fIsotopeTableList->size() ) {
00938 fIsotopeTable = (*fIsotopeTableList)[index];
00939 }
00940 return fIsotopeTable;
00941 }
00942
00943
00945 G4IsotopeProperty* G4IonTable::FindIsotope(G4int Z, G4int A, G4double E, G4int )
00946 {
00947 if (fIsotopeTableList ==0) return 0;
00948 if (fIsotopeTableList->size()==0) return 0;
00949
00950
00951 G4IsotopeProperty* property =0;
00952
00953
00954 for (size_t i = 0; i< fIsotopeTableList->size(); ++i) {
00955 G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i];
00956 G4IsotopeProperty* tmp = fIsotopeTable->GetIsotope(Z,A,E);
00957 if ( tmp !=0) {
00958
00959 #ifdef G4VERBOSE
00960 if (GetVerboseLevel()>1) {
00961 G4cout << "G4IonTable::FindIsotope:";
00962 G4cout << " Z: " << Z;
00963 G4cout << " A: " << A;
00964 G4cout << " E: " << E;
00965 G4cout << G4endl;
00966 tmp->DumpInfo();
00967 }
00968 #endif
00969 if (property !=0) {
00970
00971 if( property->GetiSpin() ==0) {
00972 property->SetiSpin( tmp->GetiSpin() );
00973 }
00974 if( property->GetMagneticMoment() <= 0.0) {
00975 property->SetMagneticMoment( tmp->GetMagneticMoment() );
00976 }
00977 if( property->GetLifeTime() <= 0.0) {
00978 property->SetLifeTime( tmp->GetLifeTime() );
00979 if ( (property->GetLifeTime() > 0.0)
00980 && (property->GetDecayTable() ==0 ) ) {
00981 property->SetDecayTable( tmp->GetDecayTable() );
00982 tmp->SetDecayTable( 0 );
00983 }
00984 }
00985 } else {
00986 property = tmp;
00987 }
00988 }
00989 }
00990
00991 return property;
00992 }
00993
00994
00996 void G4IonTable::CreateAllIon()
00997 {
00998 G4int Z;
00999 G4int A;
01000 G4double E=0.0;
01001 G4int J=0;
01002
01003 for (Z=1; Z<=120; Z++) {
01004 for (A=Z;A<999 && A<Z*3+10; A++) {
01005 if (G4NucleiProperties::IsInStableTable(A,Z)){
01006 GetIon(Z,A,E,J);
01007 }
01008 }
01009 }
01010 }
01011
01013 G4ParticleDefinition* G4IonTable::GetParticle(G4int index) const
01014 {
01015 if ( (index >=0) && (index < Entries()) ) {
01016 G4IonList::iterator idx = fIonList->begin();
01017 G4int counter = 0;
01018 while( idx != fIonList->end() ){
01019 if ( counter == index ) {
01020 return const_cast<G4ParticleDefinition*>(idx->second);
01021 }
01022 counter++;
01023 idx++;
01024 }
01025 }
01026 #ifdef G4VERBOSE
01027 if (GetVerboseLevel()>1){
01028 G4cerr << " G4IonTable::GetParticle"
01029 << " invalid index (=" << index << ")"
01030 << " entries = " << Entries() << G4endl;
01031 }
01032 #endif
01033 return 0;
01034 }
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045