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 | #ifndef G4_CASCADE_FUNCTIONS_HH |
---|
27 | #define G4_CASCADE_FUNCTIONS_HH |
---|
28 | |
---|
29 | #include <vector> |
---|
30 | #include "globals.hh" |
---|
31 | #include "G4CascadeChannel.hh" |
---|
32 | |
---|
33 | template <class T> |
---|
34 | class G4CascadeFunctions |
---|
35 | { |
---|
36 | public: |
---|
37 | static G4double getCrossSection(double ke); |
---|
38 | static G4int getMultiplicity(G4double ke); |
---|
39 | static std::vector<G4int> getOutgoingParticleTypes(G4int mult, G4double ke); |
---|
40 | }; |
---|
41 | |
---|
42 | template <class T> |
---|
43 | inline |
---|
44 | G4double |
---|
45 | G4CascadeFunctions<T>::getCrossSection(double ke) |
---|
46 | { |
---|
47 | std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); |
---|
48 | G4int k = epair.first; |
---|
49 | G4double fraction = epair.second; |
---|
50 | return T::data.tot[k] + fraction*(T::data.tot[k+1] - T::data.tot[k]); |
---|
51 | } |
---|
52 | |
---|
53 | template <class T> |
---|
54 | inline |
---|
55 | G4int |
---|
56 | G4CascadeFunctions<T>::getMultiplicity(G4double ke) |
---|
57 | { |
---|
58 | G4double multint(0.0); |
---|
59 | std::vector<G4double> sigma; |
---|
60 | |
---|
61 | std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); |
---|
62 | G4int k = epair.first; |
---|
63 | G4double fraction = epair.second; |
---|
64 | |
---|
65 | for (G4int m = 0; m < 6; ++m) |
---|
66 | { |
---|
67 | multint = T::data.multiplicities[m][k] |
---|
68 | + fraction * (T::data.multiplicities[m][k+1] - T::data.multiplicities[m][k]); |
---|
69 | sigma.push_back(multint); |
---|
70 | } |
---|
71 | |
---|
72 | return G4CascadeChannel::sampleFlat(sigma); |
---|
73 | } |
---|
74 | |
---|
75 | template <class T> |
---|
76 | inline |
---|
77 | std::vector<G4int> |
---|
78 | G4CascadeFunctions<T>::getOutgoingParticleTypes(G4int mult, G4double ke) |
---|
79 | { |
---|
80 | G4int i; |
---|
81 | G4double sigint(0.); |
---|
82 | std::vector<G4double> sigma; |
---|
83 | |
---|
84 | std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); |
---|
85 | G4int k = epair.first; |
---|
86 | G4double fraction = epair.second; |
---|
87 | |
---|
88 | G4int start = T::data.index[mult-2][0]; |
---|
89 | G4int stop = T::data.index[mult-2][1]; |
---|
90 | |
---|
91 | for (i = start; i < stop; i++) { |
---|
92 | sigint = T::data.crossSections[i][k] |
---|
93 | + fraction*(T::data.crossSections[i][k+1] - T::data.crossSections[i][k]); |
---|
94 | sigma.push_back(sigint); |
---|
95 | } |
---|
96 | |
---|
97 | G4int channel = G4CascadeChannel::sampleFlat(sigma); |
---|
98 | |
---|
99 | std::vector<G4int> kinds; |
---|
100 | |
---|
101 | if (mult == 2) { |
---|
102 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x2bfs[channel][i]); |
---|
103 | } else if (mult == 3) { |
---|
104 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x3bfs[channel][i]); |
---|
105 | } else if (mult == 4) { |
---|
106 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x4bfs[channel][i]); |
---|
107 | } else if (mult == 5) { |
---|
108 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x5bfs[channel][i]); |
---|
109 | } else if (mult == 6) { |
---|
110 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x6bfs[channel][i]); |
---|
111 | } else if (mult == 7) { |
---|
112 | for(i = 0; i < mult; i++) kinds.push_back(T::data.x7bfs[channel][i]); |
---|
113 | } else { |
---|
114 | G4cout << " Illegal multiplicity " << G4endl; |
---|
115 | } |
---|
116 | |
---|
117 | return kinds; |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | #endif |
---|