[824] | 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 | // |
---|
[1196] | 27 | // $Id: G4ShortLivedTable.cc,v 1.17 2009/08/17 14:52:19 kurasige Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[824] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class implementation file |
---|
| 33 | // |
---|
| 34 | // History: first implementation, based on object model of |
---|
| 35 | // 27 June 1998 H.Kurashige |
---|
| 36 | // ------------------------------------------------------------ |
---|
| 37 | // added Remove() 06 Nov.,98 H.Kurashige |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | #include "G4ShortLivedTable.hh" |
---|
| 41 | #include "G4ParticleTable.hh" |
---|
| 42 | |
---|
| 43 | #include "G4ios.hh" |
---|
| 44 | |
---|
| 45 | G4ShortLivedTable::G4ShortLivedTable() |
---|
| 46 | { |
---|
| 47 | fShortLivedList = new G4ShortLivedList(); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | G4ShortLivedTable::~G4ShortLivedTable() |
---|
| 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 | |
---|
| 61 | G4int G4ShortLivedTable::GetVerboseLevel() const |
---|
| 62 | { |
---|
| 63 | return G4ParticleTable::GetParticleTable()->GetVerboseLevel(); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | G4bool G4ShortLivedTable::IsShortLived(G4ParticleDefinition* particle) const |
---|
| 67 | { |
---|
| 68 | return particle->IsShortLived(); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | void G4ShortLivedTable::Insert(G4ParticleDefinition* particle) |
---|
| 72 | { |
---|
| 73 | if (IsShortLived(particle)) { |
---|
| 74 | fShortLivedList->push_back(particle); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | void G4ShortLivedTable::Remove(G4ParticleDefinition* particle) |
---|
| 79 | { |
---|
| 80 | if (IsShortLived(particle)) { |
---|
| 81 | G4ShortLivedList::iterator idx; |
---|
| 82 | for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) { |
---|
| 83 | if ( particle == *idx) { |
---|
| 84 | fShortLivedList->erase(idx); |
---|
| 85 | break; |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | } else { |
---|
| 89 | #ifdef G4VERBOSE |
---|
[850] | 90 | if (GetVerboseLevel()>1) { |
---|
[824] | 91 | G4cout << "G4ShortLivedTable::Remove :" << particle->GetParticleName() ; |
---|
| 92 | G4cout << " is not short lived" << G4endl; |
---|
| 93 | } |
---|
| 94 | #endif |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | void G4ShortLivedTable::DumpTable(const G4String &particle_name) const |
---|
| 100 | { |
---|
| 101 | G4ParticleDefinition* particle; |
---|
| 102 | |
---|
| 103 | G4ShortLivedList::iterator idx; |
---|
| 104 | for (idx = fShortLivedList->begin(); idx!= fShortLivedList->end(); ++idx) { |
---|
| 105 | particle = *idx; |
---|
| 106 | if (( particle_name == "ALL" ) || (particle_name == "all")){ |
---|
| 107 | particle->DumpTable(); |
---|
| 108 | } else if ( particle_name == particle->GetParticleName() ) { |
---|
| 109 | particle->DumpTable(); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|