00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "globals.hh"
00040 #include "G4DecayTable.hh"
00041 #include "Randomize.hh"
00042
00043 G4DecayTable::G4DecayTable():parent(0)
00044 {
00045 channels = new G4VDecayChannelVector;
00046 }
00047
00048 G4DecayTable::~G4DecayTable()
00049 {
00050
00051 G4VDecayChannelVector::iterator i;
00052 for (i = channels->begin(); i!= channels->end(); ++i) {
00053 delete (*i);
00054 }
00055 channels->clear();
00056 delete channels;
00057 channels = 0;
00058 }
00059
00060 void G4DecayTable::Insert( G4VDecayChannel * aChannel){
00061 if (parent == 0) { parent = (G4ParticleDefinition*)(aChannel->GetParent()); }
00062 if (parent != aChannel->GetParent()) {
00063 #ifdef G4VERBOSE
00064 G4cerr << " G4DecayTable::Insert :: bad G4VDecayChannel (mismatch parent) "
00065 << " " << parent->GetParticleName()
00066 << " input:" << aChannel->GetParent()->GetParticleName() << G4endl;
00067 #endif
00068 } else {
00069 G4double r = aChannel->GetBR();
00070 G4VDecayChannelVector::iterator i;
00071 for (i = channels->begin(); i!= channels->end(); ++i) {
00072 if (r > (*i)->GetBR()) {
00073 channels->insert(i,aChannel);
00074 return;
00075 }
00076 }
00077 channels->push_back(aChannel);
00078 }
00079 }
00080
00081 G4VDecayChannel *G4DecayTable::SelectADecayChannel()
00082 {
00083
00084 if (channels->size()<1) return 0;
00085
00086 while (1) {
00087 G4double sumBR = 0.0;
00088 G4double r= G4UniformRand();
00089
00090 G4VDecayChannelVector::iterator i;
00091 for (i = channels->begin(); i!= channels->end(); ++i) {
00092 sumBR += (*i)->GetBR();
00093 if (r < sumBR) {
00094 return (*i);
00095 }
00096 }
00097 }
00098 return 0;
00099 }
00100
00101 void G4DecayTable::DumpInfo() const
00102 {
00103 G4cout << "G4DecayTable: " << parent->GetParticleName() << G4endl;
00104 G4int index =0;
00105 G4VDecayChannelVector::iterator i;
00106 for (i = channels->begin(); i!= channels->end(); ++i) {
00107 G4cout << index << ": ";
00108 (*i)->DumpInfo();
00109 index +=1;
00110 }
00111 G4cout << G4endl;
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123