00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // -------------------------------------------------------------- 00031 // GEANT 4 class implementation file 00032 // 00033 // History: first implementation, based on object model of 00034 // 27 June 1998 H.Kurashige 00035 // ------------------------------------------------------------ 00036 // added Remove() 06 Nov.,98 H.Kurashige 00037 00038 00039 #include "G4ShortLivedTable.hh" 00040 #include "G4ParticleTable.hh" 00041 #include "G4StateManager.hh" 00042 00043 #include "G4ios.hh" 00044 00045 G4ShortLivedTable::G4ShortLivedTable() 00046 { 00047 fShortLivedList = new G4ShortLivedList(); 00048 } 00049 00050 G4ShortLivedTable::~G4ShortLivedTable() 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 } 00060 00061 G4ShortLivedTable::G4ShortLivedTable(const G4ShortLivedTable & right) 00062 { 00063 fShortLivedList = new G4ShortLivedList(*(right.fShortLivedList)); 00064 } 00065 00066 G4ShortLivedTable & G4ShortLivedTable::operator=(const G4ShortLivedTable &right) 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 } 00079 00080 G4int G4ShortLivedTable::GetVerboseLevel() const 00081 { 00082 return G4ParticleTable::GetParticleTable()->GetVerboseLevel(); 00083 } 00084 00085 G4bool G4ShortLivedTable::IsShortLived(const G4ParticleDefinition* particle) const 00086 { 00087 return particle->IsShortLived(); 00088 } 00089 00090 void G4ShortLivedTable::clear() 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 } 00101 00102 void G4ShortLivedTable::Insert(const G4ParticleDefinition* particle) 00103 { 00104 if (IsShortLived(particle)) { 00105 fShortLivedList->push_back(particle); 00106 } 00107 } 00108 00109 void G4ShortLivedTable::Remove(const G4ParticleDefinition* particle) 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 } 00148 00149 00150 void G4ShortLivedTable::DumpTable(const G4String &particle_name) const 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 } 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175