Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/particles/management/src/G4IonTable.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4IonTable.cc,v 1.61 2010/05/20 01:01:07 kurasige 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 $
    2929//
    3030//
     
    367367  // Search ions with A, Z ,E
    368368  //  !! J is omitted now !!
    369   G4ParticleDefinition* ion=0;
     369  const G4ParticleDefinition* ion=0;
    370370  G4bool isFound = false;
    371371
     
    386386
    387387  if ( isFound ){
    388     return ion;
     388    return const_cast<G4ParticleDefinition*>(ion);
    389389  } else {
    390390    return 0;
     
    414414  // Search ions with A, Z ,E
    415415  //  !! J is omitted now !!
    416   G4ParticleDefinition* ion=0;
     416  const G4ParticleDefinition* ion=0;
    417417  G4bool isFound = false;
    418418
     
    435435
    436436  if ( isFound ){
    437     return ion;
     437    return const_cast<G4ParticleDefinition*>(ion);
    438438  } else {
    439439    return 0;
     
    599599
    600600  // 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
    602607   
    603   //  particles derived from G4VIon and G4Ions
     608  //  particles derived from G4Ions
    604609  if (particle->GetParticleType() == nucleus) return true;
    605610
     
    611616
    612617/////////////////
     618G4bool 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/////////////////
    613642#include <algorithm>
    614643
    615 G4bool G4IonTable::IsLightIon(G4ParticleDefinition* particle) const
    616 {
    617   static const std::string names[] = { "proton", "neutron", "alpha", "deuteron",
    618                            "triton", "He3", "GenericIon"};
     644G4bool G4IonTable::IsLightIon(const G4ParticleDefinition* particle) const
     645{
     646  static const std::string names[] = { "proton", "alpha", "deuteron",
     647                           "triton", "He3"};
    619648
    620649   // 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
     653G4bool 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;
    622660}
    623661
     
    627665  // returns pointer to pre-defined ions
    628666  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;
    635672 
    636673  if (!isInitialized) {
    637674    p_proton   = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton
    638     p_neutron  = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); // neutron
    639675    p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron
    640676    p_triton   = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon
     
    644680  }
    645681
    646   G4ParticleDefinition* ion=0;
     682  const G4ParticleDefinition* ion=0;
    647683  if ( (Z<=2) ) {
    648684    if ( (Z==1)&&(A==1) ) {
    649685      ion = p_proton;
    650     } else if ( (Z==0)&&(A==1) ) {
    651       ion = p_neutron;
    652686    } else if ( (Z==1)&&(A==2) ) {
    653687      ion = p_deuteron;
     
    660694    }
    661695  }
    662   return ion;
    663 }
     696  return const_cast<G4ParticleDefinition*>(ion);
     697}
     698
     699/////////////////
     700G4ParticleDefinition* 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
    664736
    665737/////////////////
     
    683755  if (L == 0) {
    684756    // calculate nucleus mass
    685     G4ParticleDefinition* ion=GetLightIon(Z, A);
     757    const G4ParticleDefinition* ion=GetLightIon(Z, A);
    686758   
    687759    if (ion!=0) {
     
    708780// -- Methods for handling conatiner  ---
    709781/////////////////
    710 void G4IonTable::Insert(G4ParticleDefinition* particle)
     782void G4IonTable::Insert(const G4ParticleDefinition* particle)
    711783{
    712784  if (!IsIon(particle)) return;
     
    718790  G4int encoding=GetNucleusEncoding(Z, A, L);
    719791
    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/////////////////
     797void G4IonTable::Remove(const G4ParticleDefinition* particle)
    726798{
    727799  if (IsIon(particle)) {
     
    757829void G4IonTable::DumpTable(const G4String &particle_name) const
    758830{
    759   G4ParticleDefinition* ion;
     831  const G4ParticleDefinition* ion;
    760832  G4IonList::iterator idx;
    761833  for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) {
     
    905977    G4int counter = 0;
    906978    while( idx != fIonList->end() ){
    907       if ( counter == index ) return idx->second;
     979      if ( counter == index ) {
     980        return const_cast<G4ParticleDefinition*>(idx->second);
     981      }
    908982      counter++;
    909983      idx++;
Note: See TracChangeset for help on using the changeset viewer.