[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 | // |
---|
| 27 | // $Id: G4DecayTable.cc,v 1.8 2006/06/29 19:25:02 gunter Exp $ |
---|
[1196] | 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 July 1996 H.Kurashige |
---|
| 36 | // ---------------------------------------- |
---|
| 37 | // implementation for STL 14 Feb. 2000 H.Kurashige |
---|
| 38 | // ------------------------------------------------------------ |
---|
| 39 | |
---|
| 40 | #include "globals.hh" |
---|
| 41 | #include "G4DecayTable.hh" |
---|
| 42 | #include "Randomize.hh" |
---|
| 43 | |
---|
| 44 | G4DecayTable::G4DecayTable():parent(0) |
---|
| 45 | { |
---|
| 46 | channels = new G4VDecayChannelVector; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | G4DecayTable::~G4DecayTable() |
---|
| 50 | { |
---|
| 51 | // remove and delete all contents |
---|
| 52 | G4VDecayChannelVector::iterator i; |
---|
| 53 | for (i = channels->begin(); i!= channels->end(); ++i) { |
---|
| 54 | delete (*i); |
---|
| 55 | } |
---|
| 56 | channels->clear(); |
---|
| 57 | delete channels; |
---|
| 58 | channels = 0; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | void G4DecayTable::Insert( G4VDecayChannel * aChannel){ |
---|
| 62 | if (parent == 0) { parent = (G4ParticleDefinition*)(aChannel->GetParent()); } |
---|
| 63 | if (parent != aChannel->GetParent()) { |
---|
| 64 | #ifdef G4VERBOSE |
---|
| 65 | G4cout << " G4DecayTable::Insert :: bad G4VDecayChannel (mismatch parent) "; |
---|
| 66 | G4cout << " " << parent->GetParticleName(); |
---|
| 67 | G4cout << " input:" << aChannel->GetParent()->GetParticleName() << G4endl; |
---|
| 68 | #endif |
---|
| 69 | } else { |
---|
| 70 | G4double r = aChannel->GetBR(); |
---|
| 71 | G4VDecayChannelVector::iterator i; |
---|
| 72 | for (i = channels->begin(); i!= channels->end(); ++i) { |
---|
| 73 | if (r > (*i)->GetBR()) { |
---|
| 74 | channels->insert(i,aChannel); |
---|
| 75 | return; |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | channels->push_back(aChannel); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | G4VDecayChannel *G4DecayTable::SelectADecayChannel() |
---|
| 83 | { |
---|
| 84 | // check if contents exist |
---|
| 85 | if (channels->size()<1) return 0; |
---|
| 86 | |
---|
| 87 | while (1) { |
---|
| 88 | G4double sumBR = 0.0; |
---|
| 89 | G4double r= G4UniformRand(); |
---|
| 90 | // select decay channel |
---|
| 91 | G4VDecayChannelVector::iterator i; |
---|
| 92 | for (i = channels->begin(); i!= channels->end(); ++i) { |
---|
| 93 | sumBR += (*i)->GetBR(); |
---|
| 94 | if (r < sumBR) { |
---|
| 95 | return (*i); |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | return 0; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | void G4DecayTable::DumpInfo() const |
---|
| 103 | { |
---|
| 104 | G4cout << "G4DecayTable: " << parent->GetParticleName() << G4endl; |
---|
| 105 | G4int index =0; |
---|
| 106 | G4VDecayChannelVector::iterator i; |
---|
| 107 | for (i = channels->begin(); i!= channels->end(); ++i) { |
---|
| 108 | G4cout << index << ": "; |
---|
| 109 | (*i)->DumpInfo(); |
---|
| 110 | index +=1; |
---|
| 111 | } |
---|
| 112 | G4cout << G4endl; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|