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 | #ifndef G4DecayStrongResonances_h |
---|
28 | #define G4DecayStrongResonances_h 1 |
---|
29 | |
---|
30 | #include "G4Fancy3DNucleus.hh" |
---|
31 | #include "G4Nucleon.hh" |
---|
32 | #include "G4Nucleus.hh" |
---|
33 | #include "G4KineticTrackVector.hh" |
---|
34 | #include "G4FragmentVector.hh" |
---|
35 | #include "G4HadFinalState.hh" |
---|
36 | #include "G4DynamicParticleVector.hh" |
---|
37 | #include "G4HadTmpUtil.hh" |
---|
38 | |
---|
39 | #include <algorithm> |
---|
40 | |
---|
41 | class G4DecayStrongResonances |
---|
42 | { |
---|
43 | public: |
---|
44 | G4DecayStrongResonances(){} |
---|
45 | ~G4DecayStrongResonances(){} |
---|
46 | |
---|
47 | private: |
---|
48 | G4int operator==(G4DecayStrongResonances& right) {return (this == &right);} |
---|
49 | G4int operator!=(G4DecayStrongResonances& right) {return (this != &right);} |
---|
50 | |
---|
51 | G4double theEnergy; |
---|
52 | |
---|
53 | public: |
---|
54 | G4ReactionProductVector* Propagate(G4KineticTrackVector* theSecondaries, G4V3DNucleus* ) |
---|
55 | { |
---|
56 | // decay the strong resonances |
---|
57 | //static int call_count = 0; |
---|
58 | //if(call_count++<10) |
---|
59 | //{ |
---|
60 | // G4cout << "Security print-out: Entering G4DecayStrongResonances::Propagate"; |
---|
61 | //} |
---|
62 | G4ReactionProductVector * theResult; |
---|
63 | try |
---|
64 | { |
---|
65 | theResult = new G4ReactionProductVector; |
---|
66 | } |
---|
67 | catch(...) |
---|
68 | { |
---|
69 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: out of memory "); |
---|
70 | } |
---|
71 | G4KineticTrackVector *result1, *secondaries, *result; |
---|
72 | if(!theSecondaries) |
---|
73 | { |
---|
74 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: 0x0 input vector "); |
---|
75 | } |
---|
76 | result1=theSecondaries; |
---|
77 | try |
---|
78 | { |
---|
79 | result=new G4KineticTrackVector(); |
---|
80 | } |
---|
81 | catch(...) |
---|
82 | { |
---|
83 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: out of memory in "); |
---|
84 | } |
---|
85 | |
---|
86 | size_t aResult=0; |
---|
87 | for (aResult=0; aResult < result1->size(); aResult++) |
---|
88 | { |
---|
89 | G4ParticleDefinition * pdef; |
---|
90 | if(!result1->operator[](aResult)) |
---|
91 | { |
---|
92 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: null pointer in input vector!!! "); |
---|
93 | } |
---|
94 | pdef=result1->operator[](aResult)->GetDefinition(); |
---|
95 | if(!pdef) |
---|
96 | { |
---|
97 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: 0x0 particle definition "); |
---|
98 | } |
---|
99 | secondaries=NULL; |
---|
100 | if ( pdef->GetPDGWidth() > 0 && pdef->GetPDGLifeTime() < 5E-17*s ) |
---|
101 | { |
---|
102 | try |
---|
103 | { |
---|
104 | secondaries = result1->operator[](aResult)->Decay(); |
---|
105 | } |
---|
106 | catch(...) |
---|
107 | { |
---|
108 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: failing in Decay "); |
---|
109 | } |
---|
110 | } |
---|
111 | if ( secondaries == NULL ) |
---|
112 | { |
---|
113 | try |
---|
114 | { |
---|
115 | result->push_back(result1->operator[](aResult)); |
---|
116 | } |
---|
117 | catch(...) |
---|
118 | { |
---|
119 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: push_back failed - out of memory "); |
---|
120 | } |
---|
121 | result1->operator[](aResult)=NULL; //protect for clearAndDestroy |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | for (size_t aSecondary=0; aSecondary<secondaries->size(); aSecondary++) |
---|
126 | { |
---|
127 | try |
---|
128 | { |
---|
129 | result1->push_back(secondaries->operator[](aSecondary)); |
---|
130 | } |
---|
131 | catch(...) |
---|
132 | { |
---|
133 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: push_back 1 failed - out of mem"); |
---|
134 | } |
---|
135 | } |
---|
136 | if(secondaries) delete secondaries; |
---|
137 | } |
---|
138 | } |
---|
139 | try |
---|
140 | { |
---|
141 | std::for_each(result1->begin(), result1->end(), G4Delete()); |
---|
142 | delete result1; |
---|
143 | } |
---|
144 | catch(...) |
---|
145 | { |
---|
146 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: memory corruption."); |
---|
147 | } |
---|
148 | |
---|
149 | // translate to ReactionProducts |
---|
150 | G4ReactionProduct * it = NULL; |
---|
151 | for(aResult=0; aResult < result->size(); aResult++) |
---|
152 | { |
---|
153 | try |
---|
154 | { |
---|
155 | it = new G4ReactionProduct(); |
---|
156 | } |
---|
157 | catch(...) |
---|
158 | { |
---|
159 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: out of memory "); |
---|
160 | } |
---|
161 | it->SetDefinition((*result)[aResult]->GetDefinition()); |
---|
162 | it->SetMass((*result)[aResult]->GetDefinition()->GetPDGMass()); |
---|
163 | it->SetTotalEnergy((*result)[aResult]->Get4Momentum().t()); |
---|
164 | it->SetMomentum((*result)[aResult]->Get4Momentum().vect()); |
---|
165 | |
---|
166 | try |
---|
167 | { |
---|
168 | theResult->push_back(it); |
---|
169 | } |
---|
170 | catch(...) |
---|
171 | { |
---|
172 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: push to result failed - out of mem."); |
---|
173 | } |
---|
174 | } |
---|
175 | try |
---|
176 | { |
---|
177 | std::for_each(result->begin(), result->end(), G4Delete()); |
---|
178 | delete result; |
---|
179 | } |
---|
180 | catch(...) |
---|
181 | { |
---|
182 | throw G4HadronicException(__FILE__, __LINE__, "DecayStrongRes: memory corruption at end."); |
---|
183 | } |
---|
184 | return theResult; |
---|
185 | } |
---|
186 | }; |
---|
187 | |
---|
188 | #endif // G4DecayStrongResonances_h |
---|
189 | |
---|
190 | |
---|