]>
Commit | Line | Data |
---|---|---|
2e967919 | 1 | /****************************************************************************** |
2 | * T H E R M I N A T O R * | |
3 | * THERMal heavy-IoN generATOR * | |
4 | * version 1.0 * | |
5 | * * | |
6 | * Authors of the model: Wojciech Broniowski, Wojciech.Broniowski@ifj.edu.pl, * | |
7 | * Wojciech Florkowski, Wojciech.Florkowski@ifj.edu.pl * | |
8 | * Authors of the code: Adam Kisiel, kisiel@if.pw.edu.pl * | |
9 | * Tomasz Taluc, ttaluc@if.pw.edu.pl * | |
10 | * Code designers: Adam Kisiel, Tomasz Taluc, Wojciech Broniowski, * | |
11 | * Wojciech Florkowski * | |
12 | * * | |
13 | * For the detailed description of the program and furhter references * | |
14 | * to the description of the model plesase refer to: nucl-th/0504047, * | |
15 | * accessibile at: http://www.arxiv.org/nucl-th/0504047 * | |
16 | * * | |
17 | * Homepage: http://hirg.if.pw.edu.pl/en/therminator/ * | |
18 | * * | |
19 | * This code can be freely used and redistributed. However if you decide to * | |
20 | * make modifications to the code, please contact the authors, especially * | |
21 | * if you plan to publish the results obtained with such modified code. * | |
22 | * Any publication of results obtained using this code must include the * | |
23 | * reference to nucl-th/0504047 and the published version of it, when * | |
24 | * available. * | |
25 | * * | |
26 | *****************************************************************************/ | |
27 | #include "DecayTable.h" | |
28 | ||
29 | using namespace std; | |
30 | ||
31 | DecayTable::DecayTable() | |
32 | { | |
33 | mDecayChannels.clear(); | |
34 | mBranchingRatios.clear(); | |
35 | } | |
36 | ||
37 | DecayTable::DecayTable(const DecayTable& aTable) | |
38 | { | |
39 | ||
40 | mDecayChannels.clear(); | |
41 | mBranchingRatios.clear(); | |
42 | for (int iter=0; iter<aTable.GetChannelCount(); iter++) | |
43 | AddDecayChannel(*(aTable.GetDecayChannel(iter))); | |
44 | } | |
45 | ||
46 | DecayTable::~DecayTable() | |
47 | { | |
48 | } | |
49 | ||
13e05f98 | 50 | DecayTable& DecayTable::operator=(const DecayTable& aTable) |
51 | { | |
52 | if (this != &aTable) { | |
53 | mDecayChannels.clear(); | |
54 | mBranchingRatios.clear(); | |
55 | for (int iter=0; iter<aTable.GetChannelCount(); iter++) | |
56 | AddDecayChannel(*(aTable.GetDecayChannel(iter))); | |
57 | } | |
58 | ||
59 | return *this; | |
60 | } | |
61 | ||
2e967919 | 62 | void |
63 | DecayTable::AddDecayChannel(DecayChannel aChannel) | |
64 | { | |
65 | mDecayChannels.push_back(aChannel); | |
66 | RecalculateBranchingRatios(); | |
67 | } | |
68 | ||
69 | void | |
70 | DecayTable::RecalculateBranchingRatios() | |
71 | { | |
72 | float tSumRatio = 0.0; | |
73 | float tCurRatio = 0.0; | |
74 | ||
75 | for (unsigned int tIter=0; tIter<mDecayChannels.size(); tIter++) | |
76 | tSumRatio += mDecayChannels[tIter].GetBranchingRatio(); | |
77 | ||
78 | for (unsigned int tIter=0; tIter<mDecayChannels.size(); tIter++) | |
79 | { | |
80 | tCurRatio += mDecayChannels[tIter].GetBranchingRatio()/tSumRatio; | |
81 | if (mBranchingRatios.size() <= tIter) | |
82 | mBranchingRatios.push_back(tCurRatio); | |
83 | else | |
84 | mBranchingRatios[tIter] = tCurRatio; | |
85 | } | |
86 | } | |
87 | ||
88 | int | |
89 | DecayTable::GetChannelCount() const | |
90 | { | |
91 | return mDecayChannels.size()-1; | |
92 | } | |
93 | ||
94 | ||
95 | const DecayChannel* | |
96 | DecayTable::GetDecayChannel(int aIndex) const | |
97 | { | |
98 | return &(mDecayChannels[aIndex]); | |
99 | } | |
100 | ||
101 | float | |
102 | DecayTable::GetDecayStep(int aIndex) | |
103 | { | |
104 | return mBranchingRatios[aIndex]; | |
105 | } | |
106 | ||
107 | int | |
108 | DecayTable::ChooseDecayChannel(double aProb) | |
109 | { | |
110 | unsigned int tChanIndex = 0; | |
111 | while ((mBranchingRatios[tChanIndex] < aProb) && (tChanIndex < mDecayChannels.size())) | |
112 | tChanIndex++; | |
113 | ||
114 | return tChanIndex; | |
115 | } | |
116 | ||
117 | int | |
118 | DecayTable::ChooseDecayChannelOrNot(double aProb) | |
119 | { | |
120 | float tSumRatio = 0.0; | |
121 | ||
122 | for (unsigned int tIter=0; tIter<mDecayChannels.size(); tIter++) { | |
123 | if ((aProb > tSumRatio) && (aProb <= tSumRatio+mDecayChannels[tIter].GetBranchingRatio())) | |
124 | return tIter; | |
125 | tSumRatio += mDecayChannels[tIter].GetBranchingRatio(); | |
126 | } | |
127 | ||
128 | return -1; | |
129 | } | |
130 |