Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4InuclSpecialFunctions.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 // $Id$
27 //
28 // 20100114 M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
29 // 20100914 M. Kelsey -- Migrate to integer A and Z. Discard pointless
30 // verbosity.
31 // 20120608 M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
32 
33 #include <cmath>
34 
36 #include "G4PhysicalConstants.hh"
37 #include "G4LorentzVector.hh"
38 #include "G4ThreeVector.hh"
39 #include "Randomize.hh"
40 
41 
43  return 0.76 + 2.2 / G4cbrt(A);
44 }
45 
47  G4double snn;
48 
49  if (e < 40.0) {
50  snn = -1174.8 / (e * e) + 3088.5 / e + 5.3107;
51  } else {
52  snn = 93074.0 / (e * e) - 11.148 / e + 22.429;
53  }
54 
55  return snn;
56 }
57 
59  G4double spn;
60 
61  if (e < 40.0) {
62  spn = -5057.4 / (e * e) + 9069.2 / e + 6.9466;
63  } else {
64  spn = 239380.0 / (e * e) + 1802.0 / e + 27.147;
65  }
66 
67  return spn;
68 }
69 
70 // calculates the nuclei Fermi energy for 0 - neutron and 1 - proton
71 
73  const G4double C = 55.4;
74  G4double arg = (ntype==0) ? G4double(A-Z)/A : G4double(Z)/A;
75 
76  return C * G4cbrt(arg*arg); // 2/3 power
77 }
78 
80  return x==0 ? 0. : (x<0?-1.:1.)*std::exp(std::log(std::fabs(x))/3.);
81 }
82 
84  return G4UniformRand();
85 }
86 
88  const G4double eps = 1.0e-6;
89  G4double r1 = inuclRndm();
90  r1 = r1 > eps ? r1 : eps;
91  G4double r2 = inuclRndm();
92  r2 = r2 > eps ? r2 : eps;
93  r2 = r2 < 1.0 - eps ? r2 : 1.0 - eps;
94 
95  return sigma * std::sin(twopi * r1) * std::sqrt(-2.0 * std::log(r2));
96 }
97 
99  return twopi * inuclRndm();
100 }
101 
102 std::pair<G4double, G4double> G4InuclSpecialFunctions::randomCOS_SIN() {
103  G4double CT = 1.0 - 2.0 * inuclRndm();
104 
105  return std::pair<G4double, G4double>(CT, std::sqrt(1.0 - CT*CT));
106 }
107 
110  G4double mass) {
111  G4double phi = randomPHI();
112  G4double pt = p * std::sqrt(std::fabs(1.0 - ct * ct));
113 
114  static G4ThreeVector pvec; // Buffers to avoid memory thrashing
115  static G4LorentzVector momr;
116 
117  pvec.set(pt*std::cos(phi), pt*std::sin(phi), p*ct);
118  momr.setVectM(pvec, mass);
119 
120  return momr;
121 }
122 
125  std::pair<G4double, G4double> COS_SIN = randomCOS_SIN();
126  G4double phi = randomPHI();
127  G4double pt = p * COS_SIN.second;
128 
129  static G4ThreeVector pvec; // Buffers to avoid memory thrashing
130  static G4LorentzVector momr;
131 
132  pvec.set(pt*std::cos(phi), pt*std::sin(phi), p*COS_SIN.first);
133  momr.setVectM(pvec, mass);
134 
135  return momr;
136 }