Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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

◆ G4ShortLivedList

Definition at line 59 of file G4ShortLivedTable.hh.

Constructor & Destructor Documentation

◆ G4ShortLivedTable() [1/2]

G4ShortLivedTable::G4ShortLivedTable ( )

Definition at line 45 of file G4ShortLivedTable.cc.

46{
47 fShortLivedList = new G4ShortLivedList();
48}
std::vector< const G4ParticleDefinition * > G4ShortLivedList

◆ G4ShortLivedTable() [2/2]

G4ShortLivedTable::G4ShortLivedTable ( const G4ShortLivedTable right)
protected

Definition at line 61 of file G4ShortLivedTable.cc.

62{
63 fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList));
64}

◆ ~G4ShortLivedTable()

G4ShortLivedTable::~G4ShortLivedTable ( )
virtual

Definition at line 50 of file G4ShortLivedTable.cc.

51{
52 if (fShortLivedList ==0) return;
53
54 // No need to delete here because all particles are dynamic objects
55
56 fShortLivedList->clear();
57 delete fShortLivedList;
58 fShortLivedList =0;
59}

Member Function Documentation

◆ clear()

void G4ShortLivedTable::clear ( )

Definition at line 90 of file G4ShortLivedTable.cc.

91{
92 if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
93 G4Exception("G4ShortLivedTable::clear()",
94 "PART116", JustWarning,
95 "No effects because readyToUse is true.");
96 return;
97 }
98
99 fShortLivedList->clear();
100}
@ JustWarning
static G4ParticleTable * GetParticleTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4ParticleTable::RemoveAllParticles().

◆ Contains()

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

Definition at line 107 of file G4ShortLivedTable.hh.

108{
109 G4ShortLivedList::iterator i;
110 for (i = fShortLivedList->begin(); i!= fShortLivedList->end(); ++i) {
111 if (**i==*particle) return true;
112 }
113 return false;
114}

◆ DumpTable()

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

Definition at line 150 of file G4ShortLivedTable.cc.

151{
152 const G4ParticleDefinition* particle;
153
154 G4ShortLivedList::iterator idx;
155 for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) {
156 particle = *idx;
157 if (( particle_name == "ALL" ) || (particle_name == "all")){
158 particle->DumpTable();
159 } else if ( particle_name == particle->GetParticleName() ) {
160 particle->DumpTable();
161 }
162 }
163}
const G4String & GetParticleName() const

◆ Entries()

G4int G4ShortLivedTable::Entries ( ) const
inline

Definition at line 116 of file G4ShortLivedTable.hh.

117{
118 return fShortLivedList->size();
119}

Referenced by GetParticle().

◆ GetParticle()

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

Definition at line 128 of file G4ShortLivedTable.hh.

129{
130 if ( (index >=0 ) && (index < Entries()) ) {
131 return const_cast<G4ParticleDefinition*>( (*fShortLivedList)[index] );
132 } else {
133 return 0;
134 }
135}

◆ GetVerboseLevel()

G4int G4ShortLivedTable::GetVerboseLevel ( ) const
protected

Definition at line 80 of file G4ShortLivedTable.cc.

81{
83}
G4int GetVerboseLevel() const

Referenced by Remove().

◆ Insert()

void G4ShortLivedTable::Insert ( const G4ParticleDefinition particle)

Definition at line 102 of file G4ShortLivedTable.cc.

103{
104 if (IsShortLived(particle)) {
105 fShortLivedList->push_back(particle);
106 }
107}
G4bool IsShortLived(const G4ParticleDefinition *) const

Referenced by G4ParticleTable::Insert().

◆ IsShortLived()

G4bool G4ShortLivedTable::IsShortLived ( const G4ParticleDefinition particle) const

Definition at line 85 of file G4ShortLivedTable.cc.

86{
87 return particle->IsShortLived();
88}

Referenced by Insert(), and Remove().

◆ operator=()

G4ShortLivedTable & G4ShortLivedTable::operator= ( const G4ShortLivedTable right)
protected

Definition at line 66 of file G4ShortLivedTable.cc.

67{
68 if (this != & right) {
69 if (fShortLivedList !=0){
70 fShortLivedList->clear();
71 delete fShortLivedList;
72 fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList));
73 } else {
74 fShortLivedList = new G4ShortLivedList();
75 }
76 }
77 return *this;
78}

◆ Remove()

void G4ShortLivedTable::Remove ( const G4ParticleDefinition particle)

Definition at line 109 of file G4ShortLivedTable.cc.

110{
111 if (G4ParticleTable::GetParticleTable()->GetReadiness()) {
113 G4ApplicationState currentState = pStateManager->GetCurrentState();
114 if (currentState != G4State_PreInit) {
115 G4String msg = "Request of removing ";
116 msg += particle->GetParticleName();
117 msg += " has No effects other than Pre_Init";
118 G4Exception("G4ShortLivedTable::Remove()",
119 "PART117", JustWarning, msg);
120 return;
121 } else {
122#ifdef G4VERBOSE
123 if (GetVerboseLevel()>0){
124 G4cout << particle->GetParticleName()
125 << " will be removed from the ShortLivedTable " << G4endl;
126 }
127#endif
128 }
129 }
130
131 if (IsShortLived(particle)) {
132 G4ShortLivedList::iterator idx;
133 for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) {
134 if ( particle == *idx) {
135 fShortLivedList->erase(idx);
136 break;
137 }
138 }
139 } else {
140#ifdef G4VERBOSE
141 if (GetVerboseLevel()>1) {
142 G4cout << "G4ShortLivedTable::Remove :" << particle->GetParticleName() ;
143 G4cout << " is not short lived" << G4endl;
144 }
145#endif
146 }
147}
G4ApplicationState
@ G4State_PreInit
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4int GetVerboseLevel() const
G4ApplicationState GetCurrentState() const
static G4StateManager * GetStateManager()

Referenced by G4ParticleTable::Remove().

◆ size()

G4int G4ShortLivedTable::size ( ) const
inline

Definition at line 121 of file G4ShortLivedTable.hh.

122{
123 return fShortLivedList->size();
124}

The documentation for this class was generated from the following files: