G4ShortLivedTable Class Reference

#include <G4ShortLivedTable.hh>


Public Types

typedef std::vector< const
G4ParticleDefinition * > 
G4ShortLivedList

Public Member Functions

 G4ShortLivedTable ()
virtual ~G4ShortLivedTable ()
G4bool IsShortLived (const G4ParticleDefinition *) const
void DumpTable (const G4String &particle_name="ALL") const
G4int Entries () const
G4bool Contains (const G4ParticleDefinition *particle) const
void Insert (const G4ParticleDefinition *particle)
void Remove (const G4ParticleDefinition *particle)
G4ParticleDefinitionGetParticle (G4int index) const
G4int size () const
void clear ()

Protected Member Functions

 G4ShortLivedTable (const G4ShortLivedTable &right)
G4ShortLivedTableoperator= (const G4ShortLivedTable &)
G4int GetVerboseLevel () const


Detailed Description

Definition at line 50 of file G4ShortLivedTable.hh.


Member Typedef Documentation

typedef std::vector<const G4ParticleDefinition*> G4ShortLivedTable::G4ShortLivedList

Definition at line 59 of file G4ShortLivedTable.hh.


Constructor & Destructor Documentation

G4ShortLivedTable::G4ShortLivedTable (  ) 

Definition at line 45 of file G4ShortLivedTable.cc.

00046 {
00047   fShortLivedList = new G4ShortLivedList();
00048 }

G4ShortLivedTable::G4ShortLivedTable ( const G4ShortLivedTable right  )  [protected]

Definition at line 61 of file G4ShortLivedTable.cc.

References fShortLivedList.

00062 {
00063   fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList)); 
00064 }

G4ShortLivedTable::~G4ShortLivedTable (  )  [virtual]

Definition at line 50 of file G4ShortLivedTable.cc.

00051 {
00052   if (fShortLivedList ==0) return;
00053 
00054   //  No need to delete here because all particles are dynamic objects
00055 
00056   fShortLivedList->clear();
00057   delete fShortLivedList;
00058   fShortLivedList =0;
00059 }


Member Function Documentation

void G4ShortLivedTable::clear (  ) 

Definition at line 90 of file G4ShortLivedTable.cc.

References G4Exception(), G4ParticleTable::GetParticleTable(), and JustWarning.

Referenced by G4ParticleTable::RemoveAllParticles().

00091 {
00092   if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
00093     G4Exception("G4ShortLivedTable::clear()",
00094                 "PART116", JustWarning,
00095                 "No effects because readyToUse is true.");    
00096     return;
00097   }
00098 
00099   fShortLivedList->clear();
00100 }

G4bool G4ShortLivedTable::Contains ( const G4ParticleDefinition particle  )  const [inline]

Definition at line 107 of file G4ShortLivedTable.hh.

00108 {
00109   G4ShortLivedList::iterator i;
00110   for (i = fShortLivedList->begin(); i!= fShortLivedList->end(); ++i) {
00111     if (**i==*particle) return true;
00112   }
00113   return false;
00114 }

void G4ShortLivedTable::DumpTable ( const G4String particle_name = "ALL"  )  const

Definition at line 150 of file G4ShortLivedTable.cc.

References G4ParticleDefinition::DumpTable(), and G4ParticleDefinition::GetParticleName().

00151 {
00152   const G4ParticleDefinition* particle;
00153 
00154   G4ShortLivedList::iterator idx;
00155   for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) {
00156     particle = *idx;
00157     if (( particle_name == "ALL" ) || (particle_name == "all")){
00158       particle->DumpTable();
00159     } else if ( particle_name == particle->GetParticleName() ) {
00160       particle->DumpTable();
00161     }
00162   }
00163 }

G4int G4ShortLivedTable::Entries (  )  const [inline]

Definition at line 116 of file G4ShortLivedTable.hh.

Referenced by GetParticle().

00117 {
00118   return fShortLivedList->size();
00119 }

G4ParticleDefinition * G4ShortLivedTable::GetParticle ( G4int  index  )  const [inline]

Definition at line 128 of file G4ShortLivedTable.hh.

References Entries().

00129 {
00130   if ( (index >=0 ) && (index < Entries()) ) {
00131     return const_cast<G4ParticleDefinition*>( (*fShortLivedList)[index] );
00132   } else {
00133     return 0; 
00134   } 
00135 }

G4int G4ShortLivedTable::GetVerboseLevel (  )  const [protected]

Definition at line 80 of file G4ShortLivedTable.cc.

References G4ParticleTable::GetParticleTable(), and G4ParticleTable::GetVerboseLevel().

Referenced by Remove().

00081 {
00082   return G4ParticleTable::GetParticleTable()->GetVerboseLevel();
00083 }

void G4ShortLivedTable::Insert ( const G4ParticleDefinition particle  ) 

Definition at line 102 of file G4ShortLivedTable.cc.

References IsShortLived().

Referenced by G4ParticleTable::Insert().

00103 {
00104   if (IsShortLived(particle)) {
00105     fShortLivedList->push_back(particle);
00106   } 
00107 }

G4bool G4ShortLivedTable::IsShortLived ( const G4ParticleDefinition  )  const

Definition at line 85 of file G4ShortLivedTable.cc.

References G4ParticleDefinition::IsShortLived().

Referenced by Insert(), and Remove().

00086 {
00087   return particle->IsShortLived();
00088 }

G4ShortLivedTable & G4ShortLivedTable::operator= ( const G4ShortLivedTable  )  [protected]

Definition at line 66 of file G4ShortLivedTable.cc.

References fShortLivedList.

00067 {
00068   if (this != & right) {
00069     if (fShortLivedList !=0){
00070       fShortLivedList->clear();
00071       delete fShortLivedList;
00072       fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList));
00073     } else {
00074       fShortLivedList = new G4ShortLivedList();
00075     }
00076   }
00077   return *this;
00078 }

void G4ShortLivedTable::Remove ( const G4ParticleDefinition particle  ) 

Definition at line 109 of file G4ShortLivedTable.cc.

References G4cout, G4endl, G4Exception(), G4State_PreInit, G4StateManager::GetCurrentState(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetParticleTable(), G4StateManager::GetStateManager(), GetVerboseLevel(), IsShortLived(), and JustWarning.

Referenced by G4ParticleTable::Remove().

00110 {
00111   if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
00112     G4StateManager* pStateManager = G4StateManager::GetStateManager();
00113     G4ApplicationState currentState = pStateManager->GetCurrentState();
00114     if (currentState != G4State_PreInit) {
00115       G4String msg = "Request of removing ";
00116       msg += particle->GetParticleName();  
00117       msg += " has No effects other than Pre_Init";
00118       G4Exception("G4ShortLivedTable::Remove()",
00119                 "PART117", JustWarning, msg);
00120       return;
00121     } else {
00122 #ifdef G4VERBOSE
00123       if (GetVerboseLevel()>0){
00124         G4cout << particle->GetParticleName()
00125                << " will be removed from the ShortLivedTable " << G4endl;
00126       }
00127 #endif
00128     }
00129   }
00130 
00131   if (IsShortLived(particle)) {
00132     G4ShortLivedList::iterator idx;
00133     for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) {
00134       if ( particle == *idx) {
00135         fShortLivedList->erase(idx);
00136         break;
00137       }
00138     }
00139   } else {
00140 #ifdef G4VERBOSE
00141     if (GetVerboseLevel()>1) {
00142       G4cout << "G4ShortLivedTable::Remove :" << particle->GetParticleName() ;
00143       G4cout << " is not short lived" << G4endl; 
00144     }
00145 #endif
00146   }
00147 }

G4int G4ShortLivedTable::size (  )  const [inline]

Definition at line 121 of file G4ShortLivedTable.hh.

00122 {
00123   return fShortLivedList->size();
00124 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:22 2013 for Geant4 by  doxygen 1.4.7