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

#include <G4DecayProducts.hh>

Public Types

typedef std::vector< G4DynamicParticle * > G4DecayProductVector
 

Public Member Functions

 G4DecayProducts ()
 
 G4DecayProducts (const G4DynamicParticle &aParticle)
 
 G4DecayProducts (const G4DecayProducts &right)
 
G4DecayProductsoperator= (const G4DecayProducts &right)
 
 ~G4DecayProducts ()
 
G4int operator== (const G4DecayProducts &right) const
 
G4int 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
 

Protected Types

enum  { MaxNumberOfProducts = 64 }
 

Detailed Description

Definition at line 47 of file G4DecayProducts.hh.

Member Typedef Documentation

◆ G4DecayProductVector

Definition at line 94 of file G4DecayProducts.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MaxNumberOfProducts 

Definition at line 96 of file G4DecayProducts.hh.

Constructor & Destructor Documentation

◆ G4DecayProducts() [1/3]

G4DecayProducts::G4DecayProducts ( )

Definition at line 50 of file G4DecayProducts.cc.

51 :numberOfProducts(0),theParentParticle(0)
52{
53 theProductVector = new G4DecayProductVector();
54}
std::vector< G4DynamicParticle * > G4DecayProductVector

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

◆ G4DecayProducts() [2/3]

G4DecayProducts::G4DecayProducts ( const G4DynamicParticle aParticle)

Definition at line 56 of file G4DecayProducts.cc.

57 :numberOfProducts(0),theParentParticle(0)
58{
59 theParentParticle = new G4DynamicParticle(aParticle);
60 theProductVector = new G4DecayProductVector();
61}

◆ G4DecayProducts() [3/3]

G4DecayProducts::G4DecayProducts ( const G4DecayProducts right)

Definition at line 63 of file G4DecayProducts.cc.

64 :numberOfProducts(0)
65{
66 theProductVector = new G4DecayProductVector();
67
68 // copy parent (Deep Copy)
69 theParentParticle = new G4DynamicParticle(*right.theParentParticle);
70
71 //copy daughters (Deep Copy)
72 for (G4int index=0; index < right.numberOfProducts; index++) {
73 G4DynamicParticle* daughter = right.theProductVector->at(index);
74 G4DynamicParticle* pDaughter = new G4DynamicParticle(*daughter);
75
76 G4double properTime = daughter->GetPreAssignedDecayProperTime();
77 if(properTime>0.0)pDaughter->SetPreAssignedDecayProperTime(properTime);
78
79 const G4DecayProducts* pPreAssigned = daughter->GetPreAssignedDecayProducts();
80 if (pPreAssigned) {
81 G4DecayProducts* pPA = new G4DecayProducts(*pPreAssigned);
82 pDaughter->SetPreAssignedDecayProducts(pPA);
83 }
84
85 theProductVector->push_back( pDaughter );
86 }
87 numberOfProducts = right.numberOfProducts;
88}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
const G4DecayProducts * GetPreAssignedDecayProducts() const
void SetPreAssignedDecayProperTime(G4double)
G4double GetPreAssignedDecayProperTime() const

◆ ~G4DecayProducts()

G4DecayProducts::~G4DecayProducts ( )

Definition at line 127 of file G4DecayProducts.cc.

128{
129 //delete parent
130 if (theParentParticle != 0) delete theParentParticle;
131
132 // delete G4DynamicParticle object
133 for (G4int index=0; index < numberOfProducts; index++) {
134 delete theProductVector->at(index);
135 }
136 theProductVector->clear();
137 numberOfProducts = 0;
138 delete theProductVector;
139}

Member Function Documentation

◆ Boost() [1/2]

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

Definition at line 188 of file G4DecayProducts.cc.

189{
190 G4double mass = theParentParticle->GetMass();
191 G4double energy = theParentParticle->GetTotalEnergy();
192 G4double momentum = 0.0;
193
194 G4ThreeVector direction(0.0,0.0,1.0);
196
197 if (energy - mass > DBL_MIN) {
198 // calcurate beta of initial state
199 momentum = theParentParticle->GetTotalMomentum();
200 direction = theParentParticle->GetMomentumDirection();
201 G4double betax = -1.0*direction.x()*momentum/energy;
202 G4double betay = -1.0*direction.y()*momentum/energy;
203 G4double betaz = -1.0*direction.z()*momentum/energy;
204
205 for (G4int index=0; index < numberOfProducts; index++) {
206 // make G4LorentzVector for secondaries
207 p4 = (theProductVector->at(index))->Get4Momentum();
208
209 // boost secondaries to theParentParticle's rest frame
210 p4.boost(betax, betay, betaz);
211
212 // boost secondaries to new frame
213 p4.boost(newbetax, newbetay, newbetaz);
214
215 // change energy/momentum
216 (theProductVector->at(index))->Set4Momentum(p4);
217 }
218 } else {
219 for (G4int index=0; index < numberOfProducts; index++) {
220 // make G4LorentzVector for secondaries
221 p4 = (theProductVector->at(index))->Get4Momentum();
222
223 // boost secondaries to new frame
224 p4.boost(newbetax, newbetay, newbetaz);
225
226 // change energy/momentum
227 (theProductVector->at(index))->Set4Momentum(p4);
228 }
229 }
230 // make G4LorentzVector for parent in its rest frame
231 mass = theParentParticle->GetMass();
232 G4LorentzVector parent4( 0.0, 0.0, 0.0, mass);
233
234 // boost parent to new frame
235 parent4.boost(newbetax, newbetay, newbetaz);
236
237 // change energy/momentum
238 theParentParticle->Set4Momentum(parent4);
239}
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
#define DBL_MIN
Definition: templates.hh:75

◆ Boost() [2/2]

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

Definition at line 176 of file G4DecayProducts.cc.

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

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

◆ DumpInfo()

void G4DecayProducts::DumpInfo ( ) const

Definition at line 311 of file G4DecayProducts.cc.

312{
313 G4cout << " ----- List of DecayProducts -----" << G4endl;
314 G4cout << " ------ Parent Particle ----------" << G4endl;
315 if (theParentParticle != 0) theParentParticle->DumpInfo();
316 G4cout << " ------ Daughter Particles ------" << G4endl;
317 for (G4int index=0; index < numberOfProducts; index++)
318 {
319 G4cout << " ----------" << index+1 << " -------------" << G4endl;
320 (theProductVector->at(index))-> DumpInfo();
321 }
322 G4cout << " ----- End List of DecayProducts -----" << G4endl;
323 G4cout << G4endl;
324}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void DumpInfo() const
void DumpInfo(G4int mode=0) const

Referenced by 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 73 of file G4DecayProducts.hh.

73{return theParentParticle;};

Referenced by G4PionDecayMakeSpin::DaughterPolarization().

◆ IsChecked()

G4bool G4DecayProducts::IsChecked ( ) const

Definition at line 241 of file G4DecayProducts.cc.

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

Referenced by G4Decay::DecayIt().

◆ operator!=()

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

Definition at line 116 of file G4DecayProducts.hh.

117{
118 return (this != (G4DecayProducts *) &right);
119}

◆ operator=()

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

Definition at line 90 of file G4DecayProducts.cc.

91{
92 G4int index;
93
94 if (this != &right)
95 {
96 // recreate parent
97 if (theParentParticle != 0) delete theParentParticle;
98 theParentParticle = new G4DynamicParticle(*right.theParentParticle);
99
100 // delete G4DynamicParticle objects
101 for (index=0; index < numberOfProducts; index++) {
102 delete theProductVector->at(index);
103 }
104 theProductVector->clear();
105
106 //copy daughters (Deep Copy)
107 for (index=0; index < right.numberOfProducts; index++) {
108 G4DynamicParticle* daughter = right.theProductVector->at(index);
109 G4DynamicParticle* pDaughter = new G4DynamicParticle(*daughter);
110
111 G4double properTime = daughter->GetPreAssignedDecayProperTime();
112 if(properTime>0.0) pDaughter->SetPreAssignedDecayProperTime(properTime);
113
114 const G4DecayProducts* pPreAssigned = daughter->GetPreAssignedDecayProducts();
115 if (pPreAssigned) {
116 G4DecayProducts* pPA = new G4DecayProducts(*pPreAssigned);
117 pDaughter->SetPreAssignedDecayProducts(pPA);
118 }
119 theProductVector->push_back( pDaughter );
120 }
121 numberOfProducts = right.numberOfProducts;
122
123 }
124 return *this;
125}

◆ operator==()

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

Definition at line 110 of file G4DecayProducts.hh.

111{
112 return (this == (G4DecayProducts *) &right);
113}

◆ operator[]()

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

Definition at line 160 of file G4DecayProducts.cc.

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

◆ PopProducts()

G4DynamicParticle * G4DecayProducts::PopProducts ( )

Definition at line 141 of file G4DecayProducts.cc.

142{
143 if ( numberOfProducts >0 ) {
144 numberOfProducts -= 1;
145 G4DynamicParticle* part = theProductVector->back();
146 theProductVector->pop_back();
147 return part;
148 } else {
149 return 0;
150 }
151}

Referenced by G4KineticTrack::Decay(), G4Decay::DecayIt(), G4UnknownDecay::DecayIt(), G4RadioactiveDecay::DecayIt(), and G4NuclearDecayChannel::DecayIt().

◆ PushProducts()

◆ SetParentParticle()

void G4DecayProducts::SetParentParticle ( const G4DynamicParticle aParticle)

Definition at line 169 of file G4DecayProducts.cc.

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

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