Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

Definition at line 94 of file G4DecayProducts.hh.

Member Enumeration Documentation

anonymous enum
protected
Enumerator
MaxNumberOfProducts 

Definition at line 96 of file G4DecayProducts.hh.

Constructor & Destructor Documentation

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

Here is the caller graph for this function:

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 }
std::vector< G4DynamicParticle * > G4DecayProductVector
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 }
void SetPreAssignedDecayProperTime(G4double)
const G4DecayProducts * GetPreAssignedDecayProducts() const
int G4int
Definition: G4Types.hh:78
std::vector< G4DynamicParticle * > G4DecayProductVector
double G4double
Definition: G4Types.hh:76
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
G4double GetPreAssignedDecayProperTime() const

Here is the call graph for this function:

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 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

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 x() const
void Boost(G4double totalEnergy, const G4ThreeVector &momentumDirection)
double z() const
G4double GetMass() const
double y() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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);
195  G4LorentzVector p4;
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 }
G4double GetTotalEnergy() const
double x() const
int G4int
Definition: G4Types.hh:78
G4double GetTotalMomentum() const
G4double GetMass() const
const G4ThreeVector & GetMomentumDirection() const
HepLorentzVector & boost(double, double, double)
void Set4Momentum(const G4LorentzVector &momentum)
G4double energy(const ThreeVector &p, const G4double m)
#define DBL_MIN
Definition: templates.hh:75
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

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 }
void DumpInfo(G4int mode=0) const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4DecayProducts::entries ( ) const
inline

Definition at line 86 of file G4DecayProducts.hh.

86 {return numberOfProducts;};

Here is the caller graph for this function:

const G4DynamicParticle* G4DecayProducts::GetParentParticle ( ) const
inline

Definition at line 73 of file G4DecayProducts.hh.

73 {return theParentParticle;};

Here is the caller graph for this function:

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  G4cout << "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  G4cout << "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  G4cout << "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  G4cout << "G4DecayProducts::IsChecked():: "
297  << " Energy/Momentum is not conserved "<< G4endl;
298  G4cout << " difference between parent energy and sum of dughters' energy : "
299  << total_energy /MeV << "[MeV] " << G4endl;
300  G4cout << " 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 }
G4double GetTotalEnergy() const
double getY() const
int G4int
Definition: G4Types.hh:78
G4double GetTotalMomentum() const
double getX() const
G4GLOB_DLL std::ostream G4cout
G4double GetMass() const
bool G4bool
Definition: G4Types.hh:79
const G4ThreeVector & GetMomentumDirection() const
G4double energy(const ThreeVector &p, const G4double m)
double getZ() const
#define DBL_MIN
Definition: templates.hh:75
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
double G4double
Definition: G4Types.hh:76
double mag() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 116 of file G4DecayProducts.hh.

117 {
118  return (this != (G4DecayProducts *) &right);
119 }
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 }
void SetPreAssignedDecayProperTime(G4double)
const G4DecayProducts * GetPreAssignedDecayProducts() const
int G4int
Definition: G4Types.hh:78
double G4double
Definition: G4Types.hh:76
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
G4double GetPreAssignedDecayProperTime() const

Here is the call graph for this function:

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

Definition at line 110 of file G4DecayProducts.hh.

111 {
112  return (this == (G4DecayProducts *) &right);
113 }
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 }
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 }

Here is the caller graph for this function:

G4int G4DecayProducts::PushProducts ( G4DynamicParticle aParticle)

Definition at line 153 of file G4DecayProducts.cc.

154 {
155  theProductVector->push_back(aParticle);
156  numberOfProducts += 1;
157  return numberOfProducts;
158 }

Here is the caller graph for this function:

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: