Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
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 // $Id: G4DecayTable.cc 105720 2017-08-16 12:38:10Z 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  :parent(nullptr), channels(nullptr)
45 {
47 }
48 
50 {
51  // remove and delete all contents
52  G4VDecayChannelVector::iterator iCh;
53  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
54  delete (*iCh);
55  }
56  channels->clear();
57  delete channels;
58  channels = nullptr;
59  parent = nullptr;
60 }
61 
63  if (parent == nullptr) {
64  parent = (G4ParticleDefinition*)(aChannel->GetParent());
65  }
66  if (parent != aChannel->GetParent()) {
67 #ifdef G4VERBOSE
68  G4cout << " G4DecayTable::Insert :: bad G4VDecayChannel (mismatch parent) "
69  << " " << parent->GetParticleName()
70  << " input:" << aChannel->GetParent()->GetParticleName() << G4endl;
71 #endif
72  } else {
73  G4double br = aChannel->GetBR();
74  G4VDecayChannelVector::iterator iCh;
75  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
76  if (br > (*iCh)->GetBR()) {
77  channels->insert(iCh,aChannel);
78  return;
79  }
80  }
81  channels->push_back(aChannel);
82  }
83 }
84 
86 {
87  // check if contents exist
88  if (channels->size()<1) return 0;
89 
90  if(parentMass<0.) parentMass=parent->GetPDGMass();
91 
92  G4VDecayChannelVector::iterator iCh;
93  G4double sumBR = 0.;
94  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
95  if ( !((*iCh)->IsOKWithParentMass(parentMass)) ) continue;
96  sumBR += (*iCh)->GetBR();
97  }
98  if (sumBR <=0.0) {
99 #ifdef G4VERBOSE
100  G4cout << " G4DecayTable::SelectADecayChannel :: no possible DecayChannel"
101  << " " << parent->GetParticleName() << G4endl;
102 #endif
103  return nullptr;
104  }
105 
106  const size_t MAX_LOOP = 10000;
107  for (size_t loop_counter=0; loop_counter <MAX_LOOP; ++loop_counter){
108  G4double sum = 0.0;
109  G4double br= sumBR*G4UniformRand();
110  // select decay channel
111  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
112  sum += (*iCh)->GetBR();
113  if ( !((*iCh)->IsOKWithParentMass(parentMass)) ) continue;
114  if (br < sum) return (*iCh);
115  }
116  }
117  return nullptr;
118 }
119 
121 {
122  G4cout << "G4DecayTable: " << parent->GetParticleName() << G4endl;
123  G4int index =0;
124  G4VDecayChannelVector::iterator iCh;
125  for (iCh = channels->begin(); iCh!= channels->end(); ++iCh) {
126  G4cout << index << ": ";
127  (*iCh)->DumpInfo();
128  index += 1;
129  }
130  G4cout << G4endl;
131 }
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
G4double GetBR() const
G4VDecayChannelVector * channels
Definition: G4DecayTable.hh:96
#define G4endl
Definition: G4ios.hh:61
G4ParticleDefinition * parent
Definition: G4DecayTable.hh:95
const G4String & GetParticleName() const
void Insert(G4VDecayChannel *aChannel)
Definition: G4DecayTable.cc:62
G4double GetPDGMass() const
double G4double
Definition: G4Types.hh:76
void DumpInfo() const
#define G4UniformRand()
Definition: Randomize.hh:53
std::vector< G4VDecayChannel * > G4VDecayChannelVector
Definition: G4DecayTable.hh:58
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4ParticleDefinition * GetParent()
G4VDecayChannel * SelectADecayChannel(G4double parentMass=-1.)
Definition: G4DecayTable.cc:85