Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ShortLivedTable.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id$
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // History: first implementation, based on object model of
34 // 27 June 1998 H.Kurashige
35 // ------------------------------------------------------------
36 // added Remove() 06 Nov.,98 H.Kurashige
37 
38 
39 #include "G4ShortLivedTable.hh"
40 #include "G4ParticleTable.hh"
41 #include "G4StateManager.hh"
42 
43 #include "G4ios.hh"
44 
46 {
47  fShortLivedList = new G4ShortLivedList();
48 }
49 
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 }
60 
62 {
63  fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList));
64 }
65 
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 }
79 
81 {
83 }
84 
86 {
87  return particle->IsShortLived();
88 }
89 
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 }
101 
103 {
104  if (IsShortLived(particle)) {
105  fShortLivedList->push_back(particle);
106  }
107 }
108 
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 }
148 
149 
150 void G4ShortLivedTable::DumpTable(const G4String &particle_name) const
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 }
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175