Geant4  10.02.p03
G4DecayProducts Class Reference

#include <G4DecayProducts.hh>

Collaboration diagram for G4DecayProducts:

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 }
 

Private Attributes

G4int numberOfProducts
 
G4DynamicParticletheParentParticle
 
G4DecayProductVectortheProductVector
 

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.

52 {
54 }
G4DecayProductVector * theProductVector
G4DynamicParticle * theParentParticle
std::vector< G4DynamicParticle * > G4DecayProductVector
Here is the caller graph for this function:

◆ G4DecayProducts() [2/3]

G4DecayProducts::G4DecayProducts ( const G4DynamicParticle aParticle)

Definition at line 56 of file G4DecayProducts.cc.

58 {
59  theParentParticle = new G4DynamicParticle(aParticle);
61 }
G4DecayProductVector * theProductVector
G4DynamicParticle * theParentParticle
std::vector< G4DynamicParticle * > G4DecayProductVector

◆ G4DecayProducts() [3/3]

G4DecayProducts::G4DecayProducts ( const G4DecayProducts right)

Definition at line 63 of file G4DecayProducts.cc.

65 {
67 
68  // copy parent (Deep Copy)
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  }
88 }
G4DecayProductVector * theProductVector
void SetPreAssignedDecayProperTime(G4double)
Int_t index
G4DynamicParticle * theParentParticle
int G4int
Definition: G4Types.hh:78
G4double GetPreAssignedDecayProperTime() const
const G4DecayProducts * GetPreAssignedDecayProducts() const
std::vector< G4DynamicParticle * > G4DecayProductVector
double G4double
Definition: G4Types.hh:76
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
Here is the call graph for this function:

◆ ~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 }
G4DecayProductVector * theProductVector
Int_t index
G4DynamicParticle * theParentParticle
int G4int
Definition: G4Types.hh:78

Member Function Documentation

◆ Boost() [1/2]

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

Definition at line 176 of file G4DecayProducts.cc.

177 {
178  // calcurate new beta
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 }
G4double GetMass() const
G4DynamicParticle * theParentParticle
void Boost(G4double totalEnergy, const G4ThreeVector &momentumDirection)
double x() const
double y() const
double z() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Boost() [2/2]

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

Definition at line 188 of file G4DecayProducts.cc.

189 {
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();
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
239 }
G4double GetMass() const
G4DecayProductVector * theProductVector
Int_t index
G4DynamicParticle * theParentParticle
G4double GetTotalMomentum() const
int G4int
Definition: G4Types.hh:78
G4double GetTotalEnergy() const
double energy
Definition: plottest35.C:25
HepLorentzVector & boost(double, double, double)
double x() const
void Set4Momentum(const G4LorentzVector &momentum)
const G4ThreeVector & GetMomentumDirection() const
#define DBL_MIN
Definition: templates.hh:75
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ 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;
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 }
G4DecayProductVector * theProductVector
Int_t index
void DumpInfo(G4int mode=0) const
G4DynamicParticle * theParentParticle
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:

◆ entries()

G4int G4DecayProducts::entries ( ) const
inline

Definition at line 86 of file G4DecayProducts.hh.

86 {return numberOfProducts;};
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetParentParticle()

const G4DynamicParticle* G4DecayProducts::GetParentParticle ( ) const
inline

Definition at line 73 of file G4DecayProducts.hh.

73 {return theParentParticle;};
G4DynamicParticle * theParentParticle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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();
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  {
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 GetMass() const
static const double MeV
Definition: G4SIunits.hh:211
G4DecayProductVector * theProductVector
Int_t index
G4DynamicParticle * theParentParticle
G4double GetTotalMomentum() const
int G4int
Definition: G4Types.hh:78
G4double GetTotalEnergy() const
double getY() const
G4GLOB_DLL std::ostream G4cout
double energy
Definition: plottest35.C:25
double getX() const
bool G4bool
Definition: G4Types.hh:79
double mag() const
TString part[npart]
double getZ() const
const G4ThreeVector & GetMomentumDirection() const
#define DBL_MIN
Definition: templates.hh:75
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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;
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 }
G4DecayProductVector * theProductVector
void SetPreAssignedDecayProperTime(G4double)
Int_t index
G4DynamicParticle * theParentParticle
int G4int
Definition: G4Types.hh:78
G4double GetPreAssignedDecayProperTime() const
const G4DecayProducts * GetPreAssignedDecayProducts() const
double G4double
Definition: G4Types.hh:76
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
Here is the call graph for this function:

◆ 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 }
G4DecayProductVector * theProductVector
Here is the caller graph for this function:

◆ PopProducts()

G4DynamicParticle * G4DecayProducts::PopProducts ( )

Definition at line 141 of file G4DecayProducts.cc.

142 {
143  if ( numberOfProducts >0 ) {
144  numberOfProducts -= 1;
146  theProductVector->pop_back();
147  return part;
148  } else {
149  return 0;
150  }
151 }
G4DecayProductVector * theProductVector
TString part[npart]
Here is the caller graph for this function:

◆ PushProducts()

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 }
G4DecayProductVector * theProductVector
Here is the caller graph for this function:

◆ 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 }
G4DynamicParticle * theParentParticle
Here is the caller graph for this function:

Member Data Documentation

◆ numberOfProducts

G4int G4DecayProducts::numberOfProducts
private

Definition at line 99 of file G4DecayProducts.hh.

◆ theParentParticle

G4DynamicParticle* G4DecayProducts::theParentParticle
private

Definition at line 100 of file G4DecayProducts.hh.

◆ theProductVector

G4DecayProductVector* G4DecayProducts::theProductVector
private

Definition at line 101 of file G4DecayProducts.hh.


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