ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DecayTable.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4DecayTable.cc
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 //
28 //
29 // ------------------------------------------------------------
30 // GEANT 4 class implementation file
31 //
32 // History: first implementation, based on object model of
33 // 27 July 1996 H.Kurashige
34 // ----------------------------------------
35 // implementation for STL 14 Feb. 2000 H.Kurashige
36 // ------------------------------------------------------------
37 
38 #include "globals.hh"
39 #include "G4DecayTable.hh"
40 #include "Randomize.hh"
41 
43  :parent(nullptr), channels(nullptr)
44 {
46 }
47 
49 {
50  // remove and delete all contents
51  G4VDecayChannelVector::iterator iCh;
52  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
53  delete (*iCh);
54  }
55  channels->clear();
56  delete channels;
57  channels = nullptr;
58  parent = nullptr;
59 }
60 
62  if (parent == nullptr) {
63  parent = (G4ParticleDefinition*)(aChannel->GetParent());
64  }
65  if (parent != aChannel->GetParent()) {
66 #ifdef G4VERBOSE
67  G4cout << " G4DecayTable::Insert :: bad G4VDecayChannel (mismatch parent) "
68  << " " << parent->GetParticleName()
69  << " input:" << aChannel->GetParent()->GetParticleName() << G4endl;
70 #endif
71  } else {
72  G4double br = aChannel->GetBR();
73  G4VDecayChannelVector::iterator iCh;
74  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
75  if (br > (*iCh)->GetBR()) {
76  channels->insert(iCh,aChannel);
77  return;
78  }
79  }
80  channels->push_back(aChannel);
81  }
82 }
83 
85 {
86  // check if contents exist
87  if (channels->size()<1) return nullptr;
88 
89  if(parentMass < 0.) parentMass=parent->GetPDGMass();
90 
91  G4VDecayChannelVector::iterator iCh;
92  G4double sumBR = 0.;
93  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
94  if ( !((*iCh)->IsOKWithParentMass(parentMass)) ) continue;
95  sumBR += (*iCh)->GetBR();
96  }
97  if (sumBR <= 0.0) {
98 #ifdef G4VERBOSE
99  G4cout << " G4DecayTable::SelectADecayChannel :: no possible DecayChannel"
100  << " " << parent->GetParticleName() << G4endl;
101 #endif
102  return nullptr;
103  }
104 
105  const size_t MAX_LOOP = 10000;
106  for (size_t loop_counter=0; loop_counter <MAX_LOOP; ++loop_counter){
107  G4double sum = 0.0;
108  G4double br= sumBR*G4UniformRand();
109  // select decay channel
110  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
111  sum += (*iCh)->GetBR();
112  if ( !((*iCh)->IsOKWithParentMass(parentMass)) ) continue;
113  if (br < sum) return (*iCh);
114  }
115  }
116  return nullptr;
117 }
118 
120 {
121  G4cout << "G4DecayTable: " << parent->GetParticleName() << G4endl;
122  G4int index =0;
123  G4VDecayChannelVector::iterator iCh;
124  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
125  G4cout << index << ": ";
126  (*iCh)->DumpInfo();
127  index += 1;
128  }
129  G4cout << G4endl;
130 }
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141