Geant4  10.02.p02
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 95470 2016-02-12 09:02:26Z 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  if(parentMass<0.) parentMass=parent->GetPDGMass();
87  const size_t MAX_LOOP = 10000;
88  for (size_t loop_counter=0; loop_counter <MAX_LOOP; ++loop_counter){
89  G4double sumBR = 0.0;
91  // select decay channel
92  G4VDecayChannelVector::iterator i;
93  for (i = channels->begin(); i!= channels->end(); ++i) {
94  sumBR += (*i)->GetBR();
95  if ( !((*i)->IsOKWithParentMass(parentMass)) ) continue;
96  if (r < sumBR) return (*i);
97  }
98  }
99  return 0;
100 }
101 
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 
G4double GetBR() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
G4VDecayChannel * SelectADecayChannel(G4double parentMass=-1.)
Definition: G4DecayTable.cc:81
G4VDecayChannelVector * channels
Definition: G4DecayTable.hh:96
void Insert(G4VDecayChannel *aChannel)
Definition: G4DecayTable.cc:60
G4double GetPDGMass() const
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()