Geant4  10.01
G4DecayTable.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: G4DecayTable.cc 69015 2013-04-15 09:46:48Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // History: first implementation, based on object model of
34 // 27 July 1996 H.Kurashige
35 // ----------------------------------------
36 // implementation for STL 14 Feb. 2000 H.Kurashige
37 // ------------------------------------------------------------
38 
39 #include "globals.hh"
40 #include "G4DecayTable.hh"
41 #include "Randomize.hh"
42 
44 {
46 }
47 
49 {
50  // remove and delete all contents
51  G4VDecayChannelVector::iterator i;
52  for (i = channels->begin(); i!= channels->end(); ++i) {
53  delete (*i);
54  }
55  channels->clear();
56  delete channels;
57  channels = 0;
58 }
59 
61  if (parent == 0) { parent = (G4ParticleDefinition*)(aChannel->GetParent()); }
62  if (parent != aChannel->GetParent()) {
63 #ifdef G4VERBOSE
64  G4cout << " G4DecayTable::Insert :: bad G4VDecayChannel (mismatch parent) "
65  << " " << parent->GetParticleName()
66  << " input:" << aChannel->GetParent()->GetParticleName() << G4endl;
67 #endif
68  } else {
69  G4double r = aChannel->GetBR();
70  G4VDecayChannelVector::iterator i;
71  for (i = channels->begin(); i!= channels->end(); ++i) {
72  if (r > (*i)->GetBR()) {
73  channels->insert(i,aChannel);
74  return;
75  }
76  }
77  channels->push_back(aChannel);
78  }
79 }
80 
82 {
83  // check if contents exist
84  if (channels->size()<1) return 0;
85 
86  while (1) {
87  G4double sumBR = 0.0;
89  // select decay channel
90  G4VDecayChannelVector::iterator i;
91  for (i = channels->begin(); i!= channels->end(); ++i) {
92  sumBR += (*i)->GetBR();
93  if (r < sumBR) {
94  return (*i);
95  }
96  }
97  }
98  return 0;
99 }
100 
102 {
103  G4cout << "G4DecayTable: " << parent->GetParticleName() << G4endl;
104  G4int index =0;
105  G4VDecayChannelVector::iterator i;
106  for (i = channels->begin(); i!= channels->end(); ++i) {
107  G4cout << index << ": ";
108  (*i)->DumpInfo();
109  index +=1;
110  }
111  G4cout << G4endl;
112 }
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
G4double GetBR() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
#define G4UniformRand()
Definition: Randomize.hh:95
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
G4VDecayChannelVector * channels
Definition: G4DecayTable.hh:96
G4VDecayChannel * SelectADecayChannel()
Definition: G4DecayTable.cc:81
void Insert(G4VDecayChannel *aChannel)
Definition: G4DecayTable.cc:60
std::vector< G4VDecayChannel * > G4VDecayChannelVector
Definition: G4DecayTable.hh:58
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * parent
Definition: G4DecayTable.hh:95
G4ParticleDefinition * GetParent()