Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DecayProducts Class Reference

#include <G4DecayProducts.hh>

Public Types

using G4DecayProductVector = std::vector<G4DynamicParticle*>
 

Public Member Functions

 G4DecayProducts ()
 
 G4DecayProducts (const G4DynamicParticle &aParticle)
 
 G4DecayProducts (const G4DecayProducts &right)
 
G4DecayProductsoperator= (const G4DecayProducts &right)
 
 ~G4DecayProducts ()
 
G4bool operator== (const G4DecayProducts &right) const
 
G4bool operator!= (const G4DecayProducts &right) const
 
const G4DynamicParticleGetParentParticle () const
 
void SetParentParticle (const G4DynamicParticle &aParticle)
 
void Boost (G4double totalEnergy, const G4ThreeVector &momentumDirection)
 
void Boost (G4double betax, G4double betay, G4double betaz)
 
G4DynamicParticlePopProducts ()
 
G4int PushProducts (G4DynamicParticle *aParticle)
 
G4DynamicParticleoperator[] (G4int anIndex) const
 
G4int entries () const
 
G4bool IsChecked () const
 
void DumpInfo () const
 

Detailed Description

Definition at line 43 of file G4DecayProducts.hh.

Member Typedef Documentation

◆ G4DecayProductVector

Definition at line 85 of file G4DecayProducts.hh.

Constructor & Destructor Documentation

◆ G4DecayProducts() [1/3]

G4DecayProducts::G4DecayProducts ( )

Definition at line 40 of file G4DecayProducts.cc.

41{
42 theProductVector = new G4DecayProductVector();
43}
std::vector< G4DynamicParticle * > G4DecayProductVector

Referenced by G4DecayProducts(), and operator=().

◆ G4DecayProducts() [2/3]

G4DecayProducts::G4DecayProducts ( const G4DynamicParticle & aParticle)

Definition at line 45 of file G4DecayProducts.cc.

46{
47 theParentParticle = new G4DynamicParticle(aParticle);
48 theProductVector = new G4DecayProductVector();
49}

◆ G4DecayProducts() [3/3]

G4DecayProducts::G4DecayProducts ( const G4DecayProducts & right)

Definition at line 51 of file G4DecayProducts.cc.

52{
53 theProductVector = new G4DecayProductVector();
54
55 // copy parent (Deep Copy)
56 theParentParticle = new G4DynamicParticle(*right.theParentParticle);
57
58 // copy daughters (Deep Copy)
59 for (G4int index = 0; index < right.numberOfProducts; ++index) {
60 G4DynamicParticle* daughter = right.theProductVector->at(index);
61 auto pDaughter = new G4DynamicParticle(*daughter);
62
63 G4double properTime = daughter->GetPreAssignedDecayProperTime();
64 if (properTime > 0.0) pDaughter->SetPreAssignedDecayProperTime(properTime);
65
66 const G4DecayProducts* pPreAssigned = daughter->GetPreAssignedDecayProducts();
67 if (pPreAssigned != nullptr) {
68 auto pPA = new G4DecayProducts(*pPreAssigned);
69 pDaughter->SetPreAssignedDecayProducts(pPA);
70 }
71 theProductVector->push_back(pDaughter);
72 }
73 numberOfProducts = right.numberOfProducts;
74}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
const G4DecayProducts * GetPreAssignedDecayProducts() const
G4double GetPreAssignedDecayProperTime() const

◆ ~G4DecayProducts()

G4DecayProducts::~G4DecayProducts ( )

Definition at line 111 of file G4DecayProducts.cc.

112{
113 // delete parent
114 delete theParentParticle;
115 theParentParticle = nullptr;
116
117 // delete G4DynamicParticle object
118 for (G4int index = 0; index < numberOfProducts; ++index) {
119 delete theProductVector->at(index);
120 }
121 theProductVector->clear();
122 numberOfProducts = 0;
123 delete theProductVector;
124 theProductVector = nullptr;
125}

Member Function Documentation

◆ Boost() [1/2]

void G4DecayProducts::Boost ( G4double betax,
G4double betay,
G4double betaz )

Definition at line 175 of file G4DecayProducts.cc.

176{
177 G4double mass = theParentParticle->GetMass();
178 G4double energy = theParentParticle->GetTotalEnergy();
179 G4double momentum = 0.0;
180
181 G4ThreeVector direction(0.0, 0.0, 1.0);
183
184 if (energy - mass > DBL_MIN) {
185 // calcurate beta of initial state
186 momentum = theParentParticle->GetTotalMomentum();
187 direction = theParentParticle->GetMomentumDirection();
188 G4double betax = -1.0 * direction.x() * momentum / energy;
189 G4double betay = -1.0 * direction.y() * momentum / energy;
190 G4double betaz = -1.0 * direction.z() * momentum / energy;
191
192 for (G4int index = 0; index < numberOfProducts; ++index) {
193 // make G4LorentzVector for secondaries
194 p4 = (theProductVector->at(index))->Get4Momentum();
195
196 // boost secondaries to theParentParticle's rest frame
197 p4.boost(betax, betay, betaz);
198
199 // boost secondaries to new frame
200 p4.boost(newbetax, newbetay, newbetaz);
201
202 // change energy/momentum
203 (theProductVector->at(index))->Set4Momentum(p4);
204 }
205 }
206 else {
207 for (G4int index = 0; index < numberOfProducts; ++index) {
208 // make G4LorentzVector for secondaries
209 p4 = (theProductVector->at(index))->Get4Momentum();
210
211 // boost secondaries to new frame
212 p4.boost(newbetax, newbetay, newbetaz);
213
214 // change energy/momentum
215 (theProductVector->at(index))->Set4Momentum(p4);
216 }
217 }
218
219 // make G4LorentzVector for parent in its rest frame
220 mass = theParentParticle->GetMass();
221 G4LorentzVector parent4(0.0, 0.0, 0.0, mass);
222
223 // boost parent to new frame
224 parent4.boost(newbetax, newbetay, newbetaz);
225
226 // change energy/momentum
227 theParentParticle->Set4Momentum(parent4);
228}
double x() const
HepLorentzVector & boost(double, double, double)
G4double GetMass() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetTotalEnergy() const
void Set4Momentum(const G4LorentzVector &momentum)
G4double GetTotalMomentum() const
G4double energy(const ThreeVector &p, const G4double m)
#define DBL_MIN
Definition templates.hh:54

◆ Boost() [2/2]

void G4DecayProducts::Boost ( G4double totalEnergy,
const G4ThreeVector & momentumDirection )

Definition at line 161 of file G4DecayProducts.cc.

162{
163 // calculate new beta
164 G4double mass = theParentParticle->GetMass();
165 G4double totalMomentum(0);
166 if (totalEnergy > mass) {
167 totalMomentum = std::sqrt((totalEnergy - mass) * (totalEnergy + mass));
168 }
169 G4double betax = momentumDirection.x() * totalMomentum / totalEnergy;
170 G4double betay = momentumDirection.y() * totalMomentum / totalEnergy;
171 G4double betaz = momentumDirection.z() * totalMomentum / totalEnergy;
172 Boost(betax, betay, betaz);
173}
double z() const
double y() const
void Boost(G4double totalEnergy, const G4ThreeVector &momentumDirection)

Referenced by Boost(), G4RadioactiveDecay::DecayAnalog(), G4Decay::DecayIt(), G4UnknownDecay::DecayIt(), and G4IntraNucleiCascader::decayTrappedParticle().

◆ DumpInfo()

void G4DecayProducts::DumpInfo ( ) const

Definition at line 301 of file G4DecayProducts.cc.

302{
303 G4cout << " ----- List of DecayProducts -----" << G4endl;
304 G4cout << " ------ Parent Particle ----------" << G4endl;
305 if (theParentParticle != nullptr) theParentParticle->DumpInfo();
306 G4cout << " ------ Daughter Particles ------" << G4endl;
307 for (G4int index = 0; index < numberOfProducts; ++index) {
308 G4cout << " ----------" << index + 1 << " -------------" << G4endl;
309 (theProductVector->at(index))->DumpInfo();
310 }
311 G4cout << " ----- End List of DecayProducts -----" << G4endl;
312 G4cout << G4endl;
313}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void DumpInfo(G4int mode=0) const

Referenced by G4RadioactiveDecay::DecayAnalog(), G4Decay::DecayIt(), G4UnknownDecay::DecayIt(), G4GeneralPhaseSpaceDecay::ManyBodyDecayIt(), G4GeneralPhaseSpaceDecay::OneBodyDecayIt(), G4GeneralPhaseSpaceDecay::ThreeBodyDecayIt(), and G4GeneralPhaseSpaceDecay::TwoBodyDecayIt().

◆ entries()

◆ GetParentParticle()

const G4DynamicParticle * G4DecayProducts::GetParentParticle ( ) const
inline

Definition at line 107 of file G4DecayProducts.hh.

108{
109 return theParentParticle;
110}

Referenced by G4PionDecayMakeSpin::DaughterPolarization().

◆ IsChecked()

G4bool G4DecayProducts::IsChecked ( ) const

Definition at line 230 of file G4DecayProducts.cc.

231{
232 G4bool returnValue = true;
233
234 // check parent
235 // energy/momentum
236 G4double parent_energy = theParentParticle->GetTotalEnergy();
237 G4ThreeVector direction = theParentParticle->GetMomentumDirection();
238 G4ThreeVector parent_momentum = direction * (theParentParticle->GetTotalMomentum());
239
240 // check momentum direction is a unit vector
241 if ((parent_momentum.mag() > 0.0) && (std::fabs(direction.mag() - 1.0) > 1.0e-6)) {
242#ifdef G4VERBOSE
243 G4cout << "G4DecayProducts::IsChecked():: "
244 << " Momentum Direction Vector of Parent is not normalized "
245 << " (=" << direction.mag() << ")" << G4endl;
246#endif
247 returnValue = false;
248 parent_momentum = parent_momentum * (1. / direction.mag());
249 }
250
251 // daughters
252 G4double mass, energy;
253 G4ThreeVector momentum;
254 G4double total_energy = parent_energy;
255 G4ThreeVector total_momentum = parent_momentum;
256
257 for (G4int index = 0; index < numberOfProducts; ++index) {
258 G4DynamicParticle* part = theProductVector->at(index);
259 mass = part->GetMass();
260 energy = part->GetTotalEnergy();
261 direction = part->GetMomentumDirection();
262 momentum = direction * (part->GetTotalMomentum());
263
264 // check momentum direction is a unit vector
265 if ((momentum.mag() > 0.0) && (std::fabs(direction.mag() - 1.0) > 1.0e-6)) {
266#ifdef G4VERBOSE
267 G4cout << "G4DecayProducts::IsChecked():: "
268 << " Momentum Direction Vector of Daughter [" << index
269 << "] is not normalized (=" << direction.mag() << ")" << G4endl;
270#endif
271 returnValue = false;
272 momentum = momentum * (1. / direction.mag());
273 }
274 // whether daughter stops or not
275 if (energy - mass < DBL_MIN) {
276#ifdef G4VERBOSE
277 G4cout << "G4DecayProducts::IsChecked():: "
278 << " Daughter [" << index << "] has no kinetic energy " << G4endl;
279#endif
280 returnValue = false;
281 }
282 total_energy -= energy;
283 total_momentum -= momentum;
284 }
285 // check energy/momentum conservation
286 if ((std::fabs(total_energy) > 1.0e-9 * MeV) || (total_momentum.mag() > 1.0e-9 * MeV)) {
287#ifdef G4VERBOSE
288 G4cout << "G4DecayProducts::IsChecked():: "
289 << " Energy/Momentum is not conserved " << G4endl;
290 G4cout << " difference between parent energy & sum of daughters energy: " << total_energy / MeV
291 << "[MeV] " << G4endl;
292 G4cout << " difference between parent momentum & sum of daughters momentum: "
293 << " x:" << total_momentum.getX() / MeV << " y:" << total_momentum.getY() / MeV
294 << " z:" << total_momentum.getZ() / MeV << G4endl;
295#endif
296 returnValue = false;
297 }
298 return returnValue;
299}
bool G4bool
Definition G4Types.hh:86
double getZ() const
double mag() const
double getX() const
double getY() const

Referenced by G4RadioactiveDecay::DecayAnalog(), and G4Decay::DecayIt().

◆ operator!=()

G4bool G4DecayProducts::operator!= ( const G4DecayProducts & right) const
inline

Definition at line 102 of file G4DecayProducts.hh.

103{
104 return (this != (G4DecayProducts*)&right);
105}

◆ operator=()

G4DecayProducts & G4DecayProducts::operator= ( const G4DecayProducts & right)

Definition at line 76 of file G4DecayProducts.cc.

77{
78 G4int index;
79
80 if (this != &right) {
81 // recreate parent
82 delete theParentParticle;
83 theParentParticle = new G4DynamicParticle(*right.theParentParticle);
84
85 // delete G4DynamicParticle objects
86 for (index = 0; index < numberOfProducts; ++index) {
87 delete theProductVector->at(index);
88 }
89 theProductVector->clear();
90
91 // copy daughters (Deep Copy)
92 for (index = 0; index < right.numberOfProducts; ++index) {
93 G4DynamicParticle* daughter = right.theProductVector->at(index);
94 auto pDaughter = new G4DynamicParticle(*daughter);
95
96 G4double properTime = daughter->GetPreAssignedDecayProperTime();
97 if (properTime > 0.0) pDaughter->SetPreAssignedDecayProperTime(properTime);
98
99 const G4DecayProducts* pPreAssigned = daughter->GetPreAssignedDecayProducts();
100 if (pPreAssigned != nullptr) {
101 auto pPA = new G4DecayProducts(*pPreAssigned);
102 pDaughter->SetPreAssignedDecayProducts(pPA);
103 }
104 theProductVector->push_back(pDaughter);
105 }
106 numberOfProducts = right.numberOfProducts;
107 }
108 return *this;
109}

◆ operator==()

G4bool G4DecayProducts::operator== ( const G4DecayProducts & right) const
inline

Definition at line 97 of file G4DecayProducts.hh.

98{
99 return (this == (G4DecayProducts*)&right);
100}

◆ operator[]()

G4DynamicParticle * G4DecayProducts::operator[] ( G4int anIndex) const

Definition at line 146 of file G4DecayProducts.cc.

147{
148 if ((numberOfProducts > anIndex) && (anIndex >= 0)) {
149 return theProductVector->at(anIndex);
150 }
151
152 return nullptr;
153}

◆ PopProducts()

G4DynamicParticle * G4DecayProducts::PopProducts ( )

Definition at line 127 of file G4DecayProducts.cc.

128{
129 if (numberOfProducts > 0) {
130 numberOfProducts -= 1;
131 G4DynamicParticle* part = theProductVector->back();
132 theProductVector->pop_back();
133 return part;
134 }
135
136 return nullptr;
137}

Referenced by G4Radioactivation::AddDeexcitationSpectrumForBiasMode(), G4KineticTrack::Decay(), G4RadioactiveDecay::DecayAnalog(), G4Decay::DecayIt(), G4Radioactivation::DecayIt(), and G4UnknownDecay::DecayIt().

◆ PushProducts()

◆ SetParentParticle()

void G4DecayProducts::SetParentParticle ( const G4DynamicParticle & aParticle)

Definition at line 155 of file G4DecayProducts.cc.

156{
157 delete theParentParticle;
158 theParentParticle = new G4DynamicParticle(aParticle);
159}

The documentation for this class was generated from the following files: