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: G4PreCompoundFragmentVector.hh,v 1.7 2010/08/28 15:16:55 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03-ref-09 $ |
---|
28 | // |
---|
29 | // Hadronic Process: Nuclear Preequilibrium |
---|
30 | // by V. Lara |
---|
31 | // |
---|
32 | // Modified: |
---|
33 | // 03.09.2008 by J. M. Quesada for external choice of inverse |
---|
34 | // cross section option |
---|
35 | // 06.09.2008 JMQ Also external choice has been added for: |
---|
36 | // - superimposed Coulomb barrier (if useSICB=true) |
---|
37 | // 27.08.2010 V.Ivanchenko simplify and make more efficient by adding extra |
---|
38 | // vector of probabilities, moved constructor and destructor to source, |
---|
39 | // simplify run time computations making inlined |
---|
40 | // |
---|
41 | |
---|
42 | #ifndef G4PreCompoundFragmentVector_h |
---|
43 | #define G4PreCompoundFragmentVector_h 1 |
---|
44 | |
---|
45 | #include "G4VPreCompoundFragment.hh" |
---|
46 | #include "G4DataVector.hh" |
---|
47 | #include "Randomize.hh" |
---|
48 | #include "globals.hh" |
---|
49 | #include <vector> |
---|
50 | |
---|
51 | typedef std::vector<G4VPreCompoundFragment*> pcfvector; |
---|
52 | |
---|
53 | class G4PreCompoundFragmentVector |
---|
54 | { |
---|
55 | public: |
---|
56 | |
---|
57 | G4PreCompoundFragmentVector(pcfvector * avector); |
---|
58 | |
---|
59 | ~G4PreCompoundFragmentVector(); |
---|
60 | |
---|
61 | void SetVector(pcfvector * avector); |
---|
62 | |
---|
63 | void SetOPTxs(G4int); |
---|
64 | |
---|
65 | void UseSICB(G4bool); |
---|
66 | |
---|
67 | inline void Initialize(const G4Fragment & aFragment); |
---|
68 | |
---|
69 | inline G4double CalculateProbabilities(const G4Fragment & aFragment); |
---|
70 | |
---|
71 | inline G4VPreCompoundFragment * ChooseFragment(); |
---|
72 | |
---|
73 | private: |
---|
74 | |
---|
75 | G4PreCompoundFragmentVector(const G4PreCompoundFragmentVector &right); |
---|
76 | const G4PreCompoundFragmentVector& |
---|
77 | operator=(const G4PreCompoundFragmentVector &right); |
---|
78 | G4bool operator==(const G4PreCompoundFragmentVector &right) const; |
---|
79 | G4bool operator!=(const G4PreCompoundFragmentVector &right) const; |
---|
80 | |
---|
81 | pcfvector * theChannels; |
---|
82 | G4DataVector probabilities; |
---|
83 | |
---|
84 | G4int nChannels; |
---|
85 | |
---|
86 | }; |
---|
87 | |
---|
88 | inline void |
---|
89 | G4PreCompoundFragmentVector::Initialize(const G4Fragment & aFragment) |
---|
90 | { |
---|
91 | for (G4int i=0; i< nChannels; ++i) { |
---|
92 | (*theChannels)[i]->Initialize(aFragment); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | inline G4double |
---|
97 | G4PreCompoundFragmentVector::CalculateProbabilities(const G4Fragment & aFragment) |
---|
98 | { |
---|
99 | //G4cout << "## G4PreCompoundFragmentVector::CalculateProbabilities" << G4endl; |
---|
100 | G4double probtot = 0.0; |
---|
101 | for (G4int i=0; i< nChannels; ++i) { |
---|
102 | G4double prob = (*theChannels)[i]->CalcEmissionProbability(aFragment); |
---|
103 | probtot += prob; |
---|
104 | probabilities[i] = probtot; |
---|
105 | //G4cout<<" prob= "<<prob<<" for "<<(*theChannels)[i]->GetName()<<G4endl; |
---|
106 | } |
---|
107 | return probtot; |
---|
108 | } |
---|
109 | |
---|
110 | inline G4VPreCompoundFragment* G4PreCompoundFragmentVector::ChooseFragment() |
---|
111 | { |
---|
112 | G4double x = probabilities[nChannels-1]*G4UniformRand(); |
---|
113 | G4int i=0; |
---|
114 | for (; i<nChannels; ++i) { |
---|
115 | if(x <= probabilities[i]) { break; } |
---|
116 | } |
---|
117 | return (*theChannels)[i]; |
---|
118 | } |
---|
119 | |
---|
120 | #endif |
---|
121 | |
---|