Geant4 10.7.0
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 86 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 {
61 G4DynamicParticle* daughter = right.theProductVector->at(index);
62 G4DynamicParticle* pDaughter = new G4DynamicParticle(*daughter);
63
64 G4double properTime = daughter->GetPreAssignedDecayProperTime();
65 if(properTime>0.0) pDaughter->SetPreAssignedDecayProperTime(properTime);
66
67 const G4DecayProducts* pPreAssigned
68 = daughter->GetPreAssignedDecayProducts();
69 if (pPreAssigned != nullptr)
70 {
71 G4DecayProducts* pPA = new G4DecayProducts(*pPreAssigned);
72 pDaughter->SetPreAssignedDecayProducts(pPA);
73 }
74 theProductVector->push_back( pDaughter );
75 }
76 numberOfProducts = right.numberOfProducts;
77}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
const G4DecayProducts * GetPreAssignedDecayProducts() const
void SetPreAssignedDecayProperTime(G4double)
G4double GetPreAssignedDecayProperTime() const

◆ ~G4DecayProducts()

G4DecayProducts::~G4DecayProducts ( )

Definition at line 119 of file G4DecayProducts.cc.

120{
121 //delete parent
122 if (theParentParticle != nullptr) delete theParentParticle;
123 theParentParticle = nullptr;
124
125 // delete G4DynamicParticle object
126 for (G4int index=0; index<numberOfProducts; ++index)
127 {
128 delete theProductVector->at(index);
129 }
130 theProductVector->clear();
131 numberOfProducts = 0;
132 delete theProductVector;
133 theProductVector = nullptr;
134}

Member Function Documentation

◆ Boost() [1/2]

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

Definition at line 193 of file G4DecayProducts.cc.

196{
197 G4double mass = theParentParticle->GetMass();
198 G4double energy = theParentParticle->GetTotalEnergy();
199 G4double momentum = 0.0;
200
201 G4ThreeVector direction(0.0,0.0,1.0);
203
204 if (energy - mass > DBL_MIN)
205 {
206 // calcurate beta of initial state
207 momentum = theParentParticle->GetTotalMomentum();
208 direction = theParentParticle->GetMomentumDirection();
209 G4double betax = -1.0*direction.x()*momentum/energy;
210 G4double betay = -1.0*direction.y()*momentum/energy;
211 G4double betaz = -1.0*direction.z()*momentum/energy;
212
213 for (G4int index=0; index<numberOfProducts; ++index)
214 {
215 // make G4LorentzVector for secondaries
216 p4 = (theProductVector->at(index))->Get4Momentum();
217
218 // boost secondaries to theParentParticle's rest frame
219 p4.boost(betax, betay, betaz);
220
221 // boost secondaries to new frame
222 p4.boost(newbetax, newbetay, newbetaz);
223
224 // change energy/momentum
225 (theProductVector->at(index))->Set4Momentum(p4);
226 }
227 }
228 else
229 {
230 for (G4int index=0; index<numberOfProducts; ++index)
231 {
232 // make G4LorentzVector for secondaries
233 p4 = (theProductVector->at(index))->Get4Momentum();
234
235 // boost secondaries to new frame
236 p4.boost(newbetax, newbetay, newbetaz);
237
238 // change energy/momentum
239 (theProductVector->at(index))->Set4Momentum(p4);
240 }
241 }
242
243 // make G4LorentzVector for parent in its rest frame
244 mass = theParentParticle->GetMass();
245 G4LorentzVector parent4( 0.0, 0.0, 0.0, mass);
246
247 // boost parent to new frame
248 parent4.boost(newbetax, newbetay, newbetaz);
249
250 // change energy/momentum
251 theParentParticle->Set4Momentum(parent4);
252}
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 177 of file G4DecayProducts.cc.

179{
180 // calculate new beta
181 G4double mass = theParentParticle->GetMass();
182 G4double totalMomentum(0);
183 if ( totalEnergy > mass )
184 {
185 totalMomentum = std::sqrt( (totalEnergy - mass)*(totalEnergy + mass) );
186 }
187 G4double betax = momentumDirection.x()*totalMomentum/totalEnergy;
188 G4double betay = momentumDirection.y()*totalMomentum/totalEnergy;
189 G4double betaz = momentumDirection.z()*totalMomentum/totalEnergy;
190 Boost(betax, betay, betaz);
191}
double z() const
double y() const
void Boost(G4double totalEnergy, const G4ThreeVector &momentumDirection)

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

◆ DumpInfo()

void G4DecayProducts::DumpInfo ( ) const

Definition at line 334 of file G4DecayProducts.cc.

335{
336 G4cout << " ----- List of DecayProducts -----" << G4endl;
337 G4cout << " ------ Parent Particle ----------" << G4endl;
338 if (theParentParticle != 0) theParentParticle->DumpInfo();
339 G4cout << " ------ Daughter Particles ------" << G4endl;
340 for (G4int index=0; index<numberOfProducts; ++index)
341 {
342 G4cout << " ----------" << index+1 << " -------------" << G4endl;
343 (theProductVector->at(index))-> DumpInfo();
344 }
345 G4cout << " ----- End List of DecayProducts -----" << G4endl;
346 G4cout << G4endl;
347}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
void DumpInfo(G4int mode=0) const

Referenced by G4RadioactiveDecayBase::DecayAnalog(), G4Decay::DecayIt(), G4UnknownDecay::DecayIt(), G4RadioactiveDecay::DecayIt(), G4DalitzDecayChannel::DecayIt(), G4KL3DecayChannel::DecayIt(), G4MuonDecayChannel::DecayIt(), G4MuonDecayChannelWithSpin::DecayIt(), G4MuonRadiativeDecayChannelWithSpin::DecayIt(), G4NeutronBetaDecayChannel::DecayIt(), G4PionRadiativeDecayChannel::DecayIt(), G4TauLeptonicDecayChannel::DecayIt(), DumpInfo(), G4GeneralPhaseSpaceDecay::ManyBodyDecayIt(), G4GeneralPhaseSpaceDecay::OneBodyDecayIt(), G4GeneralPhaseSpaceDecay::ThreeBodyDecayIt(), and G4GeneralPhaseSpaceDecay::TwoBodyDecayIt().

◆ entries()

◆ GetParentParticle()

const G4DynamicParticle * G4DecayProducts::GetParentParticle ( ) const
inline

Definition at line 112 of file G4DecayProducts.hh.

113{
114 return theParentParticle;
115}

Referenced by G4PionDecayMakeSpin::DaughterPolarization().

◆ IsChecked()

G4bool G4DecayProducts::IsChecked ( ) const

Definition at line 254 of file G4DecayProducts.cc.

255{
256 G4bool returnValue = true;
257
258 // check parent
259 // energy/momentum
260 G4double parent_energy = theParentParticle->GetTotalEnergy();
261 G4ThreeVector direction = theParentParticle->GetMomentumDirection();
262 G4ThreeVector parent_momentum
263 = direction*(theParentParticle->GetTotalMomentum());
264
265 // check momentum direction is a unit vector
266 if ((parent_momentum.mag() >0.0) && (std::fabs(direction.mag()-1.0) >1.0e-6))
267 {
268#ifdef G4VERBOSE
269 G4cout << "G4DecayProducts::IsChecked():: "
270 << " Momentum Direction Vector of Parent is not normalized "
271 << " (=" << direction.mag() << ")" << G4endl;
272#endif
273 returnValue = false;
274 parent_momentum = parent_momentum * (1./direction.mag());
275 }
276
277 // daughters
278 G4double mass, energy;
279 G4ThreeVector momentum;
280 G4double total_energy = parent_energy;
281 G4ThreeVector total_momentum = parent_momentum;
282
283 for (G4int index=0; index < numberOfProducts; ++index)
284 {
285 G4DynamicParticle* part = theProductVector->at(index);
286 mass = part->GetMass();
287 energy = part->GetTotalEnergy();
288 direction = part->GetMomentumDirection();
289 momentum = direction*(part->GetTotalMomentum());
290
291 // check momentum direction is a unit vector
292 if ( (momentum.mag()>0.0) && (std::fabs(direction.mag()-1.0) > 1.0e-6))
293 {
294#ifdef G4VERBOSE
295 G4cout << "G4DecayProducts::IsChecked():: "
296 << " Momentum Direction Vector of Daughter [" << index
297 << "] is not normalized (=" << direction.mag() << ")" << G4endl;
298#endif
299 returnValue = false;
300 momentum = momentum * (1./direction.mag());
301 }
302 // whether daughter stops or not
303 if (energy - mass < DBL_MIN )
304 {
305#ifdef G4VERBOSE
306 G4cout << "G4DecayProducts::IsChecked():: "
307 << " Daughter [" << index << "] has no kinetic energy "<< G4endl;
308#endif
309 returnValue = false;
310 }
311 total_energy -= energy;
312 total_momentum -= momentum;
313 }
314 // check energy/momentum conservation
315 if ( (std::fabs(total_energy) >1.0e-9*MeV)
316 || (total_momentum.mag() >1.0e-9*MeV ) )
317 {
318#ifdef G4VERBOSE
319 G4cout << "G4DecayProducts::IsChecked():: "
320 << " Energy/Momentum is not conserved "<< G4endl;
321 G4cout << " difference between parent energy & sum of daughters energy: "
322 << total_energy /MeV << "[MeV] " << G4endl;
323 G4cout << " difference between parent momentum & sum of daughters momentum: "
324 << " x:" << total_momentum.getX()/MeV
325 << " y:" << total_momentum.getY()/MeV
326 << " z:" << total_momentum.getZ()/MeV
327 << G4endl;
328#endif
329 returnValue = false;
330 }
331 return returnValue;
332}
bool G4bool
Definition: G4Types.hh:86
double getZ() const
double mag() const
double getX() const
double getY() const

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

◆ operator!=()

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

Definition at line 106 of file G4DecayProducts.hh.

107{
108 return (this != (G4DecayProducts *) &right);
109}

◆ operator=()

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

Definition at line 79 of file G4DecayProducts.cc.

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

◆ operator==()

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

Definition at line 100 of file G4DecayProducts.hh.

101{
102 return (this == (G4DecayProducts *) &right);
103}

◆ operator[]()

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

Definition at line 158 of file G4DecayProducts.cc.

159{
160 if ((numberOfProducts > anIndex) && (anIndex >=0) )
161 {
162 return theProductVector->at(anIndex);
163 }
164 else
165 {
166 return nullptr;
167 }
168}

◆ PopProducts()

G4DynamicParticle * G4DecayProducts::PopProducts ( )

Definition at line 136 of file G4DecayProducts.cc.

137{
138 if ( numberOfProducts >0 )
139 {
140 numberOfProducts -= 1;
141 G4DynamicParticle* part = theProductVector->back();
142 theProductVector->pop_back();
143 return part;
144 }
145 else
146 {
147 return nullptr;
148 }
149}

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

◆ PushProducts()

◆ SetParentParticle()

void G4DecayProducts::SetParentParticle ( const G4DynamicParticle aParticle)

Definition at line 170 of file G4DecayProducts.cc.

171{
172 if (theParentParticle != nullptr) delete theParentParticle;
173 theParentParticle = new G4DynamicParticle(aParticle);
174}

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