Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VEmissionProbability.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// Hadronic Process: Nuclear De-excitations
27// by V. Lara (Oct 1998)
28//
29// Modifications:
30// 28.10.2010 V.Ivanchenko defined members in constructor and cleaned up
31
33#include "G4NuclearLevelData.hh"
34#include "G4LevelManager.hh"
36#include "Randomize.hh"
37#include "G4Pow.hh"
38#include "G4Log.hh"
39#include "G4Exp.hh"
40
48
57
59{
60 if(de > 0.0) { elimit = de; }
61 if(eps > 0.0) { accuracy = eps; }
62}
63
68
73
75 G4double ehigh,
76 G4double cb)
77{
78 pProbability = 0.0;
79 if(elow >= ehigh) { return pProbability; }
80
81 emin = elow;
82 emax = ehigh;
83 eCoulomb = cb;
84
85 const G4double edeltamin = 0.1*CLHEP::MeV;
86 const G4double edeltamax = 2*CLHEP::MeV;
87 G4double edelta = std::min(std::min(elimit, edeltamax), edeltamin);
88 G4double xbin = (emax - emin)/edelta + 1.0;
89 G4int ibin = std::max((G4int)xbin, 4);
90
91 // providing smart binning
92 G4int nbin = ibin*5;
93 edelta = (emax - emin)/ibin;
94
95 G4double x(emin), y(0.0);
96 G4double edelmicro = edelta*0.02;
97 probmax = ComputeProbability(x + edelmicro, eCoulomb);
98 G4double problast = probmax;
99 if(pVerbose > 1) {
100 G4cout << "### G4VEmissionProbability::IntegrateProbability: "
101 << "probmax=" << probmax << " Emin=" << emin
102 << " Emax=" << emax << " QB=" << cb << " nbin=" << nbin
103 << G4endl;
104 }
105 fE1 = fE2 = fP2 = 0.0;
106 G4double emax0 = emax - edelmicro;
107 G4bool endpoint = false;
108 for(G4int i=0; i<nbin; ++i) {
109 x += edelta;
110 if(x >= emax0) {
111 x = emax0;
112 endpoint = true;
113 }
114 y = ComputeProbability(x, eCoulomb);
115 if(pVerbose > 2) {
116 G4cout << " " << i << ". E= " << x << " prob= " << y
117 << " Edel= " << edelta << G4endl;
118 }
119 if(y >= probmax) {
120 probmax = y;
121 } else if(0.0 == fE1 && 2*y < probmax) {
122 fE1 = x;
123 }
124
125 G4double del = (y + problast)*edelta*0.5;
126 pProbability += del;
127 // end of the loop
128 if(del < accuracy*pProbability || endpoint) { break; }
129 problast = y;
130
131 // smart step definition
132 if(del != pProbability && del > 0.8*pProbability &&
133 0.7*edelta > edeltamin) {
134 edelta *= 0.7;
135 } else if(del < 0.1*pProbability && 1.5*edelta < edeltamax) {
136 edelta *= 1.5;
137 }
138 }
139 if(fE1 > emin && fE1 < emax) {
140 fE2 = std::max(0.5*(fE1 + emax), emax - edelta);
141 fP2 = 2*ComputeProbability(fE2, eCoulomb);
142 }
143
144 if(pVerbose > 1) {
145 G4cout << " Probability= " << pProbability << " probmax= "
146 << probmax << " emin=" << emin << " emax=" << emax
147 << " E1=" << fE1 << " E2=" << fE2 << G4endl;
148 }
149 return pProbability;
150}
151
153{
154 static const G4double fact = 1.05;
155 static const G4double alim = 0.05;
156 static const G4double blim = 20.;
157 probmax *= fact;
158
159 // two regions with flat and exponential majorant
160 G4double del = emax - emin;
161 G4double p1 = 1.0;
162 G4double p2 = 0.0;
163 G4double a0 = 0.0;
164 G4double a1 = 1.0;
165 G4double x;
166 if(fE1 > 0.0 && fP2 > 0.0 && fP2 < 0.5*probmax) {
167 a0 = G4Log(probmax/fP2)/(fE2 - fE1);
168 del= fE1 - emin;
169 p1 = del;
170 x = a0*(emax - fE1);
171 if(x < blim) {
172 a1 = (x > alim) ? 1.0 - G4Exp(-x) : x*(1.0 - 0.5*x);
173 }
174 p2 = a1/a0;
175 p1 /= (p1 + p2);
176 p2 = 1.0 - p1;
177 }
178
179 if(pVerbose > 1) {
180 G4cout << "### G4VEmissionProbability::SampleEnergy: "
181 << " Emin= " << emin << " Emax= " << emax
182 << "/n E1=" << fE1 << " p1=" << p1
183 << " probmax=" << probmax << " P2=" << fP2 << G4endl;
184 }
185
186 CLHEP::HepRandomEngine* rndm = G4Random::getTheEngine();
187 const G4int nmax = 1000;
188 G4double ekin, g, gmax;
189 G4int n = 0;
190 do {
191 ++n;
192 G4double q = rndm->flat();
193 if(q <= p1) {
194 gmax = probmax;
195 ekin = del*q/p1 + emin;
196 } else {
197 ekin = fE1 - G4Log(1.0 - (q - p1)*a1/p2)/a0;
198 x = a0*(ekin - fE1);
199 gmax = fP2;
200 if(x < blim) {
201 gmax = probmax*((x > alim) ? G4Exp(-x) : 1.0 - x*(1.0 - 0.5*x));
202 }
203 }
204 g = ComputeProbability(ekin, eCoulomb);
205 if(pVerbose > 2) {
206 G4cout << " " << n
207 << ". prob= " << g << " probmax= " << probmax
208 << " Ekin= " << ekin << G4endl;
209 }
210 if((g > gmax || n > nmax) && pVerbose > 1) {
211 G4cout << "### G4VEmissionProbability::SampleEnergy for Z= " << theZ
212 << " A= " << theA << " Eex(MeV)=" << fExc << " p1=" << p1
213 << "\n Warning n= " << n
214 << " prob/gmax=" << g/gmax
215 << " prob=" << g << " gmax=" << gmax << " probmax=" << probmax
216 << "\n Ekin= " << ekin << " Emin= " << emin
217 << " Emax= " << emax << G4endl;
218 }
219 } while(gmax*rndm->flat() > g && n < nmax);
220 G4double enew = FindRecoilExcitation(ekin);
221 if(pVerbose > 1) {
222 G4cout << "### SampleEnergy: Efinal= "
223 << enew << " E=" << ekin << " Eexc=" << fExcRes << G4endl;
224 }
225 return enew;
226}
227
228G4double G4VEmissionProbability::FindRecoilExcitation(const G4double e)
229{
230 G4double mass = pEvapMass + fExc;
231
232 G4double m02 = pMass*pMass;
233 G4double m12 = mass*mass;
235 G4double mres = std::sqrt(m02 + m12 - 2.*pMass*(mass + e));
236
237 fExcRes = mres - pResMass;
238
239 if(pVerbose > 1) {
240 G4cout << "### FindRecoilExcitation for resZ= "
241 << resZ << " resA= " << resA
242 << " evaporated Z= " << theZ << " A= " << theA
243 << " Ekin= " << e << " Eexc= " << fExcRes << G4endl;
244 }
245
246 // residual nucleus is in the ground state
247 if(fExcRes < pTolerance) {
248 fExcRes = 0.0;
249 return std::max(0.5*(m02 + m12 - m22)/pMass - mass, 0.0);
250 }
251 if(!fFD) { return e; }
252
253 // select final state excitation
254 auto lManager = pNuclearLevelData->GetLevelManager(resZ, resA);
255 if(nullptr == lManager) { return e; }
256
257 // levels are not known
258 if(fExcRes > lManager->MaxLevelEnergy() + pTolerance) { return e; }
259
260 // find level
261 G4double elevel = lManager->NearestLevelEnergy(fExcRes);
262
263 // excited level
264 if(pMass > mass + pResMass + elevel &&
265 std::abs(elevel - fExcRes) <= pTolerance) {
266 G4double massR = pResMass + elevel;
267 G4double mr2 = massR*massR;
268 fExcRes = elevel;
269 return std::max(0.5*(m02 + m12 - mr2)/pMass - mass, 0.0);
270 }
271 return e;
272}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:180
const G4double a0
G4double G4Log(G4double x)
Definition G4Log.hh:227
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
const G4double A[17]
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
virtual double flat()=0
G4bool GetDiscreteExcitationFlag() const
G4double NearestLevelEnergy(const G4double energy, const std::size_t index=0) const
G4DeexPrecoParameters * GetParameters()
const G4LevelManager * GetLevelManager(G4int Z, G4int A)
static G4NuclearLevelData * GetInstance()
static G4double GetNuclearMass(const G4double A, const G4double Z)
static G4Pow * GetInstance()
Definition G4Pow.cc:41
G4VEmissionProbability(G4int Z, G4int A)
void ResetIntegrator(size_t nbin, G4double de, G4double eps)
G4double IntegrateProbability(G4double elow, G4double ehigh, G4double CB)
virtual G4double ComputeProbability(G4double anEnergy, G4double CB)
virtual G4double EmissionProbability(const G4Fragment &fragment, G4double anEnergy)
G4NuclearLevelData * pNuclearLevelData