Changeset 1340 for trunk/source/particles/management/src/G4IonTable.cc
- Timestamp:
- Nov 5, 2010, 3:45:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/particles/management/src/G4IonTable.cc
r1337 r1340 25 25 // 26 26 // 27 // $Id: G4IonTable.cc,v 1.6 1 2010/05/20 01:01:07kurasige Exp $28 // GEANT4 tag $Name: geant4-09-04-beta-01$27 // $Id: G4IonTable.cc,v 1.65 2010/10/16 06:04:51 kurasige Exp $ 28 // GEANT4 tag $Name: particles-V09-03-15 $ 29 29 // 30 30 // … … 367 367 // Search ions with A, Z ,E 368 368 // !! J is omitted now !! 369 G4ParticleDefinition* ion=0;369 const G4ParticleDefinition* ion=0; 370 370 G4bool isFound = false; 371 371 … … 386 386 387 387 if ( isFound ){ 388 return ion;388 return const_cast<G4ParticleDefinition*>(ion); 389 389 } else { 390 390 return 0; … … 414 414 // Search ions with A, Z ,E 415 415 // !! J is omitted now !! 416 G4ParticleDefinition* ion=0;416 const G4ParticleDefinition* ion=0; 417 417 G4bool isFound = false; 418 418 … … 435 435 436 436 if ( isFound ){ 437 return ion;437 return const_cast<G4ParticleDefinition*>(ion); 438 438 } else { 439 439 return 0; … … 599 599 600 600 // neutron is not ion 601 if ((particle->GetAtomicMass() >0) && (particle->GetAtomicNumber()>0)) return true; 601 if ((particle->GetAtomicMass()>0) && 602 (particle->GetAtomicNumber()>0) ){ 603 if (particle->GetBaryonNumber()>0) return true; 604 else return false; 605 } 606 602 607 603 // particles derived from G4 VIon and G4Ions608 // particles derived from G4Ions 604 609 if (particle->GetParticleType() == nucleus) return true; 605 610 … … 611 616 612 617 ///////////////// 618 G4bool G4IonTable::IsAntiIon(const G4ParticleDefinition* particle) 619 { 620 // return true if the particle is ion 621 622 static G4String anti_nucleus("anti_nucleus"); 623 static G4String anti_proton("anti_proton"); 624 625 // anti_neutron is not ion 626 if ((particle->GetAtomicMass()>0) && 627 (particle->GetAtomicNumber()>0) ){ 628 if (particle->GetBaryonNumber()<0) return true; 629 else return false; 630 } 631 632 // particles derived from G4Ions 633 if (particle->GetParticleType() == anti_nucleus) return true; 634 635 // anti_proton (Anti_Hydrogen nucleus) 636 if (particle->GetParticleName() == anti_proton) return true; 637 638 return false; 639 } 640 641 ///////////////// 613 642 #include <algorithm> 614 643 615 G4bool G4IonTable::IsLightIon( G4ParticleDefinition* particle) const616 { 617 static const std::string names[] = { "proton", " neutron", "alpha", "deuteron",618 "triton", "He3" , "GenericIon"};644 G4bool G4IonTable::IsLightIon(const G4ParticleDefinition* particle) const 645 { 646 static const std::string names[] = { "proton", "alpha", "deuteron", 647 "triton", "He3"}; 619 648 620 649 // return true if the particle is pre-defined ion 621 return std::find(names, names+7, particle->GetParticleName())!=names+7; 650 return std::find(names, names+5, particle->GetParticleName())!=names+5; 651 } 652 653 G4bool G4IonTable::IsLightAntiIon(const G4ParticleDefinition* particle) const 654 { 655 static const std::string names[] = { "anti_proton", "anti_alpha", "anti_deuteron", 656 "anti_triton", "anti_He3"}; 657 658 // return true if the particle is pre-defined ion 659 return std::find(names, names+5, particle->GetParticleName())!=names+5; 622 660 } 623 661 … … 627 665 // returns pointer to pre-defined ions 628 666 static G4bool isInitialized = false; 629 static G4ParticleDefinition* p_proton=0; 630 static G4ParticleDefinition* p_neutron=0; 631 static G4ParticleDefinition* p_deuteron=0; 632 static G4ParticleDefinition* p_triton=0; 633 static G4ParticleDefinition* p_alpha=0; 634 static G4ParticleDefinition* p_He3=0; 667 static const G4ParticleDefinition* p_proton=0; 668 static const G4ParticleDefinition* p_deuteron=0; 669 static const G4ParticleDefinition* p_triton=0; 670 static const G4ParticleDefinition* p_alpha=0; 671 static const G4ParticleDefinition* p_He3=0; 635 672 636 673 if (!isInitialized) { 637 674 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton 638 p_neutron = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); // neutron639 675 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron 640 676 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon … … 644 680 } 645 681 646 G4ParticleDefinition* ion=0;682 const G4ParticleDefinition* ion=0; 647 683 if ( (Z<=2) ) { 648 684 if ( (Z==1)&&(A==1) ) { 649 685 ion = p_proton; 650 } else if ( (Z==0)&&(A==1) ) {651 ion = p_neutron;652 686 } else if ( (Z==1)&&(A==2) ) { 653 687 ion = p_deuteron; … … 660 694 } 661 695 } 662 return ion; 663 } 696 return const_cast<G4ParticleDefinition*>(ion); 697 } 698 699 ///////////////// 700 G4ParticleDefinition* G4IonTable::GetLightAntiIon(G4int Z, G4int A) const 701 { 702 // returns pointer to pre-defined ions 703 static G4bool isInitialized = false; 704 static const G4ParticleDefinition* p_proton=0; 705 static const G4ParticleDefinition* p_deuteron=0; 706 static const G4ParticleDefinition* p_triton=0; 707 static const G4ParticleDefinition* p_alpha=0; 708 static const G4ParticleDefinition* p_He3=0; 709 710 if (!isInitialized) { 711 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("anti_proton"); // proton 712 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("anti_deuteron"); // deuteron 713 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("anti_triton"); // tritoon 714 p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("anti_alpha"); // alpha 715 p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("anti_He3"); // He3 716 isInitialized = true; 717 } 718 719 const G4ParticleDefinition* ion=0; 720 if ( (Z<=2) ) { 721 if ( (Z==1)&&(A==1) ) { 722 ion = p_proton; 723 } else if ( (Z==1)&&(A==2) ) { 724 ion = p_deuteron; 725 } else if ( (Z==1)&&(A==3) ) { 726 ion = p_triton; 727 } else if ( (Z==2)&&(A==4) ) { 728 ion = p_alpha; 729 } else if ( (Z==2)&&(A==3) ) { 730 ion = p_He3; 731 } 732 } 733 return const_cast<G4ParticleDefinition*>(ion); 734 } 735 664 736 665 737 ///////////////// … … 683 755 if (L == 0) { 684 756 // calculate nucleus mass 685 G4ParticleDefinition* ion=GetLightIon(Z, A);757 const G4ParticleDefinition* ion=GetLightIon(Z, A); 686 758 687 759 if (ion!=0) { … … 708 780 // -- Methods for handling conatiner --- 709 781 ///////////////// 710 void G4IonTable::Insert( G4ParticleDefinition* particle)782 void G4IonTable::Insert(const G4ParticleDefinition* particle) 711 783 { 712 784 if (!IsIon(particle)) return; … … 718 790 G4int encoding=GetNucleusEncoding(Z, A, L); 719 791 720 fIonList->insert( std::pair< G4int,G4ParticleDefinition*>(encoding, particle) );721 722 } 723 724 ///////////////// 725 void G4IonTable::Remove( G4ParticleDefinition* particle)792 fIonList->insert( std::pair<const G4int, const G4ParticleDefinition*>(encoding, particle) ); 793 794 } 795 796 ///////////////// 797 void G4IonTable::Remove(const G4ParticleDefinition* particle) 726 798 { 727 799 if (IsIon(particle)) { … … 757 829 void G4IonTable::DumpTable(const G4String &particle_name) const 758 830 { 759 G4ParticleDefinition* ion;831 const G4ParticleDefinition* ion; 760 832 G4IonList::iterator idx; 761 833 for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { … … 905 977 G4int counter = 0; 906 978 while( idx != fIonList->end() ){ 907 if ( counter == index ) return idx->second; 979 if ( counter == index ) { 980 return const_cast<G4ParticleDefinition*>(idx->second); 981 } 908 982 counter++; 909 983 idx++;
Note: See TracChangeset
for help on using the changeset viewer.