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: G4PreCompoundFragmentVector.cc,v 1.5 2006/06/29 20:59:21 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // Hadronic Process: Nuclear Preequilibrium |
---|
31 | // by V. Lara |
---|
32 | |
---|
33 | #include "G4PreCompoundFragmentVector.hh" |
---|
34 | #include "G4HadronicException.hh" |
---|
35 | |
---|
36 | const G4PreCompoundFragmentVector & |
---|
37 | G4PreCompoundFragmentVector:: |
---|
38 | operator=(const G4PreCompoundFragmentVector &) |
---|
39 | { |
---|
40 | throw G4HadronicException(__FILE__, __LINE__, "G4PreCompoundFragmentVector::operator= meant to not be accessable"); |
---|
41 | return *this; |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | G4bool G4PreCompoundFragmentVector:: |
---|
46 | operator==(const G4PreCompoundFragmentVector &) const |
---|
47 | { |
---|
48 | return false; |
---|
49 | } |
---|
50 | |
---|
51 | G4bool G4PreCompoundFragmentVector:: |
---|
52 | operator!=(const G4PreCompoundFragmentVector &) const |
---|
53 | { |
---|
54 | return true; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | G4double G4PreCompoundFragmentVector:: |
---|
60 | CalculateProbabilities(const G4Fragment & aFragment) |
---|
61 | { |
---|
62 | TotalEmissionProbability = 0.0; |
---|
63 | pcfvector::iterator aChannel; |
---|
64 | for (aChannel=theChannels->begin(); aChannel != theChannels->end(); |
---|
65 | aChannel++) |
---|
66 | { |
---|
67 | // Calculate emission probailities |
---|
68 | // Compute total (integrated over kinetic energy) emission |
---|
69 | // probability of a fragment and |
---|
70 | // Summing channel emission probabilities |
---|
71 | TotalEmissionProbability += (*aChannel)->CalcEmissionProbability(aFragment); |
---|
72 | } |
---|
73 | return TotalEmissionProbability; |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | G4VPreCompoundFragment * G4PreCompoundFragmentVector:: |
---|
78 | ChooseFragment(void) |
---|
79 | { |
---|
80 | const G4int NumOfFrags = theChannels->size(); |
---|
81 | std::vector<G4double> running; |
---|
82 | running.reserve(NumOfFrags); |
---|
83 | |
---|
84 | pcfvector::iterator i; |
---|
85 | G4double accumulation = 0.0; |
---|
86 | for (i = theChannels->begin(); i != theChannels->end(); ++i) { |
---|
87 | accumulation += (*i)->GetEmissionProbability(); |
---|
88 | running.push_back(accumulation); |
---|
89 | } |
---|
90 | |
---|
91 | // Choose an emission channel |
---|
92 | G4double aChannel = G4UniformRand()*TotalEmissionProbability; |
---|
93 | G4int ChosenChannel = -1; |
---|
94 | std::vector<G4double>::iterator ich; |
---|
95 | for (ich = running.begin(); ich != running.end(); ++ich) |
---|
96 | { |
---|
97 | if (aChannel <= *ich) |
---|
98 | { |
---|
99 | #ifdef G4NO_ISO_VECDIST |
---|
100 | std::vector<G4double>::difference_type n = 0; |
---|
101 | std::distance(running.begin(),ich,n); |
---|
102 | ChosenChannel = n; |
---|
103 | #else |
---|
104 | ChosenChannel = std::distance(running.begin(),ich); |
---|
105 | #endif |
---|
106 | break; |
---|
107 | } |
---|
108 | } |
---|
109 | running.clear(); |
---|
110 | if (ChosenChannel < 0) |
---|
111 | { |
---|
112 | G4cerr |
---|
113 | << "G4PreCompoundFragmentVector::ChooseFragment: I can't determine a channel\n" |
---|
114 | << "Probabilities: "; |
---|
115 | for (i = theChannels->begin(); i != theChannels->end(); ++i) |
---|
116 | { |
---|
117 | G4cout << (*i)->GetEmissionProbability() << " "; |
---|
118 | } |
---|
119 | G4cout << '\n'; |
---|
120 | return 0; |
---|
121 | } |
---|
122 | else |
---|
123 | { |
---|
124 | for (i = theChannels->begin(); i != theChannels->end(); ++i) |
---|
125 | { |
---|
126 | (*i)->IncrementStage(); |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | return theChannels->operator[](ChosenChannel); |
---|
131 | } |
---|