Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4DynamicParticle.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4DynamicParticle.cc 110257 2018-05-17 14:20:12Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // History: first implementation, based on object model of
34 // 2nd December 1995, G.Cosmo
35 // ---------------- G4DynamicParticle ----------------
36 // first implementation by Makoto Asai, 29 January 1996
37 // revised by G.Cosmo, 29 February 1996
38 // revised by H.Kurashige 06 May 1996
39 // revised by Hisaya Kurashige, 27 July 1996
40 // modify thePreAssignedDecayProducts
41 // add void SetMomentum(G4ThreeVector &momentum)
42 // add void Set4Momentum(G4LorentzVector &momentum)
43 // add G4DynamicParticle(G4ParticleDefinition * aParticleDefinition,
44 // G4LorentzVector &p4vector)
45 // revised by Hisaya Kurashige, 19 Oct 1996
46 // add theKillProcess
47 // add ProperTime
48 // revised by Hisaya Kurashige, 26 Mar 1997
49 // modify destructor
50 // revised by Hisaya Kurashige, 05 June 1997
51 // modify DumpInfo()
52 // revised by Hisaya Kurashige, 5 June 1998
53 // remove theKillProcess
54 // revised by Hisaya Kurashige, 5 Mar 2001
55 // fixed SetDefinition()
56 // revised by V.Ivanchenko, 12 June 2003
57 // fixed problem of massless particles
58 // revised by V.Ivanchenko, 18 June 2003
59 // take into account the case of virtual photons
60 // revised by M.Kelsey 12 May 2010
61 // ensure that all constructors initialize all data members
62 //--------------------------------------------------------------
63 
64 #include "G4DynamicParticle.hh"
65 #include "G4PhysicalConstants.hh"
66 #include "G4SystemOfUnits.hh"
67 #include "G4DecayProducts.hh"
68 #include "G4LorentzVector.hh"
69 #include "G4ParticleDefinition.hh"
70 #include "G4ParticleTable.hh"
71 #include "G4IonTable.hh"
72 #include "G4PrimaryParticle.hh"
73 
75 {
77  return _instance;
78 }
79 
81 
84  theMomentumDirection(0.0,0.0,1.0),
85  theParticleDefinition(0),
86  theKineticEnergy(0.0),
87  theProperTime(0.0),
88  theDynamicalMass(0.0),
89  theDynamicalCharge(0.0),
90  theDynamicalSpin(0.0),
91  theDynamicalMagneticMoment(0.0),
92  theElectronOccupancy(0),
93  thePreAssignedDecayProducts(0),
94  thePreAssignedDecayTime(-1.0),
95  verboseLevel(1),
96  primaryParticle(0),
97  thePDGcode(0)
98 {
99 }
100 
102 // -- constructors ----
105  const G4ThreeVector& aMomentumDirection,
106  G4double aKineticEnergy):
107  theMomentumDirection(aMomentumDirection),
108  theParticleDefinition(aParticleDefinition),
109  theKineticEnergy(aKineticEnergy),
110  theProperTime(0.0),
111  theDynamicalMass(aParticleDefinition->GetPDGMass()),
112  theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
113  theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
114  theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
115  theElectronOccupancy(0),
116  thePreAssignedDecayProducts(0),
117  thePreAssignedDecayTime(-1.0),
118  verboseLevel(1),
119  primaryParticle(0),
120  thePDGcode(0)
121 {
122 }
123 
126  const G4ThreeVector& aMomentumDirection,
127  G4double aKineticEnergy,
128  const G4double dynamicalMass):
129  theMomentumDirection(aMomentumDirection),
130  theParticleDefinition(aParticleDefinition),
131  theKineticEnergy(aKineticEnergy),
132  theProperTime(0.0),
133  theDynamicalMass(aParticleDefinition->GetPDGMass()),
134  theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
135  theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
136  theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
137  theElectronOccupancy(0),
138  thePreAssignedDecayProducts(0),
139  thePreAssignedDecayTime(-1.0),
140  verboseLevel(1),
141  primaryParticle(0),
142  thePDGcode(0)
143 {
144  if (std::abs(theDynamicalMass-dynamicalMass)> EnergyMomentumRelationAllowance) {
145  if (dynamicalMass>EnergyMomentumRelationAllowance) theDynamicalMass= dynamicalMass;
146  else theDynamicalMass= 0.0;
147  }
148 }
149 
152  const G4ThreeVector& aParticleMomentum):
153  theParticleDefinition(aParticleDefinition),
154  theKineticEnergy(0.0),
155  theProperTime(0.0),
156  theDynamicalMass(aParticleDefinition->GetPDGMass()),
157  theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
158  theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
159  theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
160  theElectronOccupancy(0),
161  thePreAssignedDecayProducts(0),
162  thePreAssignedDecayTime(-1.0),
163  verboseLevel(1),
164  primaryParticle(0),
165  thePDGcode(0)
166 {
167  SetMomentum(aParticleMomentum); // 3-dim momentum is given
168 }
169 
170 
173  const G4LorentzVector &aParticleMomentum):
174  theParticleDefinition(aParticleDefinition),
175  theKineticEnergy(0.0),
176  theProperTime(0.0),
177  theDynamicalMass(aParticleDefinition->GetPDGMass()),
178  theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
179  theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
180  theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
181  theElectronOccupancy(0),
182  thePreAssignedDecayProducts(0),
183  thePreAssignedDecayTime(-1.0),
184  verboseLevel(1),
185  primaryParticle(0),
186  thePDGcode(0)
187 {
188  Set4Momentum(aParticleMomentum); // 4-momentum vector (Lorentz vector) is given
189 }
190 
192  G4double totalEnergy,
193  const G4ThreeVector &aParticleMomentum):
194  theParticleDefinition(aParticleDefinition),
195  theKineticEnergy(0.0),
196  theProperTime(0.0),
197  theDynamicalMass(aParticleDefinition->GetPDGMass()),
198  theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
199  theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
200  theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
201  theElectronOccupancy(0),
202  thePreAssignedDecayProducts(0),
203  thePreAssignedDecayTime(-1.0),
204  verboseLevel(1),
205  primaryParticle(0),
206  thePDGcode(0)
207 {
208  // total energy and 3-dim momentum are given
209  G4double pModule2 = aParticleMomentum.mag2();
210  if (pModule2>0.0) {
211  G4double mass2 = totalEnergy*totalEnergy - pModule2;
212  G4double PDGmass2 = (aParticleDefinition->GetPDGMass())*(aParticleDefinition->GetPDGMass());
213  SetMomentumDirection(aParticleMomentum.unit());
215  theDynamicalMass = 0.;
216  SetKineticEnergy(totalEnergy);
217  } else {
218  if (std::abs(PDGmass2-mass2)>EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance){
219  theDynamicalMass = std::sqrt(mass2);
220  SetKineticEnergy(totalEnergy-theDynamicalMass);
221  } else {
222  SetKineticEnergy(totalEnergy-theDynamicalMass);
223  }
224  }
225  } else {
226  SetMomentumDirection(1.0,0.0,0.0);
227  SetKineticEnergy(0.0);
228  }
229 }
230 
233  theMomentumDirection(right.theMomentumDirection),
234  theParticleDefinition(right.theParticleDefinition),
235  thePolarization(right.thePolarization),
236  theKineticEnergy(right.theKineticEnergy),
237  theProperTime(0.0),
238  theDynamicalMass(right.theDynamicalMass),
239  theDynamicalCharge(right.theDynamicalCharge),
240  theDynamicalSpin(right.theDynamicalSpin),
241  theDynamicalMagneticMoment(right.theDynamicalMagneticMoment),
242  theElectronOccupancy(0),
243  thePreAssignedDecayProducts(0), // Do not copy preassignedDecayProducts
244  thePreAssignedDecayTime(-1.0),
245  verboseLevel(right.verboseLevel),
246  primaryParticle(right.primaryParticle),
247  thePDGcode(right.thePDGcode)
248 {
249  if (right.theElectronOccupancy != 0) {
252  }
253 }
254 
256 // -- destructor ----
259 {
260  // delete thePreAssignedDecayProducts
263 
266 }
267 
268 
270 // -- operators ----
273 {
274  if (this != &right) {
280 
285 
287  if (right.theElectronOccupancy != 0){
290  } else {
292  }
293 
294  // thePreAssignedDecayProducts must not be copied.
297 
298  verboseLevel = right.verboseLevel;
299 
300  // Primary particle information must be preserved
301  //*** primaryParticle = right.primaryParticle;
302 
303  thePDGcode = right.thePDGcode;
304  }
305  return *this;
306 }
307 
310 {
311  // remove preassigned decay
312  if (thePreAssignedDecayProducts != 0) {
313 #ifdef G4VERBOSE
314  if (verboseLevel>0) {
315  G4cout << " G4DynamicParticle::SetDefinition()::"
316  << "!!! Pre-assigned decay products is attached !!!! " << G4endl;
317  G4cout << "!!! New Definition is " << aParticleDefinition->GetParticleName()
318  << " !!! " << G4endl;
319  G4cout << "!!! Pre-assigned decay products will be deleted !!!! " << G4endl;
320  }
321 #endif
323  }
325 
326  theParticleDefinition = aParticleDefinition;
327 
328  // set Dynamic mass/chrge
333 
334  // Set electron orbits
337  //AllocateElectronOccupancy();
338 
339 }
340 
343 {
344  return (this == (G4DynamicParticle *) &right);
345 }
346 
349 {
350  return (this != (G4DynamicParticle *) &right);
351 }
352 
353 
354 
356 // -- AllocateElectronOccupancy --
359 {
360  const G4ParticleDefinition* particle = GetDefinition();
361 
362  if (G4IonTable::IsIon(particle)) {
363  // Only ions can have ElectronOccupancy
365 
366  } else {
368 
369  }
370 }
371 
373 // -- methods for setting Energy/Momentum --
376 {
377  G4double pModule2 = momentum.mag2();
378  if (pModule2>0.0) {
379  G4double mass = theDynamicalMass;
380  SetMomentumDirection(momentum.unit());
381  SetKineticEnergy(std::sqrt(pModule2 + mass*mass)-mass);
382  } else {
383  SetMomentumDirection(1.0,0.0,0.0);
384  SetKineticEnergy(0.0);
385  }
386 }
387 
390 {
391  G4double pModule2 = momentum.vect().mag2();
392  if (pModule2>0.0) {
393  SetMomentumDirection(momentum.vect().unit());
394  G4double totalenergy = momentum.t();
395  G4double mass2 = totalenergy*totalenergy - pModule2;
398  theDynamicalMass = 0.;
399  } else if (std::abs(PDGmass2-mass2)>EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance){
400  theDynamicalMass = std::sqrt(mass2);
401  }
402  SetKineticEnergy(totalenergy-theDynamicalMass);
403  } else {
404  SetMomentumDirection(1.0,0.0,0.0);
405  SetKineticEnergy(0.0);
406  }
407 }
408 
409 
411 // --- Dump Information --
413 #ifdef G4VERBOSE
414 void G4DynamicParticle::DumpInfo(G4int mode) const
415 {
416  if (theParticleDefinition == 0) {
417  G4cout << " G4DynamicParticle::DumpInfo():: !!!Particle type not defined !!!! " << G4endl;
418  } else {
419  G4cout << " Particle type - " << theParticleDefinition->GetParticleName() << G4endl
420  << " mass: " << GetMass()/GeV << "[GeV]" <<G4endl
421  << " charge: " << GetCharge()/eplus << "[e]" <<G4endl
422  << " Direction x: " << GetMomentumDirection().x() << ", y: "
423  << GetMomentumDirection().y() << ", z: "
424  << GetMomentumDirection().z() << G4endl
425  << " Total Momentum = " << GetTotalMomentum() /GeV << "[GeV]" << G4endl
426  << " Momentum: " << GetMomentum().x() /GeV << "[GeV]" << ", y: "
427  << GetMomentum().y() /GeV << "[GeV]" << ", z: "
428  << GetMomentum().z() /GeV << "[GeV]" << G4endl
429  << " Total Energy = " << GetTotalEnergy()/GeV << "[GeV]" << G4endl
430  << " Kinetic Energy = " << GetKineticEnergy() /GeV << "[GeV]" << G4endl
431  << " MagneticMoment [MeV/T]: " << GetMagneticMoment()/MeV*tesla << G4endl
432  << " ProperTime = " << GetProperTime() /ns << "[ns]" << G4endl;
433 
434  if (mode>0) {
435  if( theElectronOccupancy != 0) {
437  }
438  }
439  }
440 }
441 #else
443 {
444  return;
445 }
446 #endif
447 //
450 {
452  theDynamicalMass = newMass;
453  }
454 }
457 {
458  static G4ThreadLocal G4double electronMass = 0.0;
459 
460  // check if electron exits and get the mass
461  if (electronMass<=0.0) {
463  if (electron == 0) {
464  G4Exception("G4DynamicParticle::GetElectronMass()","PART021",
465  FatalException,"G4DynamicParticle: G4Electron is not defined !!");
466  }
467  electronMass = electron->GetPDGMass();
468  }
469 
470  return electronMass;
471 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetMass(G4double mass)
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1148
G4int operator==(const G4DynamicParticle &right) const
static G4ParticleTable * GetParticleTable()
static constexpr double MeV
Definition: G4SIunits.hh:214
void SetKineticEnergy(G4double aEnergy)
static constexpr double keV
Definition: G4SIunits.hh:216
#define G4endl
Definition: G4ios.hh:61
const G4ThreeVector & GetMomentumDirection() const
G4ThreeVector thePolarization
const G4String & GetParticleName() const
G4double thePreAssignedDecayTime
G4double GetPDGCharge() const
double z() const
#define G4ThreadLocal
Definition: tls.hh:69
#define G4ThreadLocalStatic
Definition: tls.hh:68
G4double GetPDGMass() const
void SetMomentumDirection(const G4ThreeVector &aDirection)
G4double GetPDGSpin() const
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetDefinition() const
G4double GetProperTime() const
G4Allocator< G4DynamicParticle > *& pDynamicParticleAllocator()
G4double GetElectronMass() const
G4DynamicParticle & operator=(const G4DynamicParticle &right)
G4double GetMagneticMoment() const
G4double GetCharge() const
void Set4Momentum(const G4LorentzVector &momentum)
G4ThreeVector theMomentumDirection
double mag2() const
const G4ParticleDefinition * theParticleDefinition
G4double GetPDGMagneticMoment() const
Hep3Vector unit() const
G4ThreeVector GetMomentum() const
static constexpr double eplus
Definition: G4SIunits.hh:199
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4ElectronOccupancy * theElectronOccupancy
G4int operator!=(const G4DynamicParticle &right) const
int G4int
Definition: G4Types.hh:78
G4DecayProducts * thePreAssignedDecayProducts
void SetMomentum(const G4ThreeVector &momentum)
G4double GetKineticEnergy() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4GLOB_DLL std::ostream G4cout
double x() const
G4double theDynamicalMagneticMoment
Hep3Vector vect() const
G4double GetMass() const
G4double GetTotalMomentum() const
G4double GetTotalEnergy() const
double y() const
static const G4double EnergyMomentumRelationAllowance
void DumpInfo(G4int mode=0) const
static constexpr double GeV
Definition: G4SIunits.hh:217
#define ns
Definition: xmlparse.cc:614
static constexpr double tesla
Definition: G4SIunits.hh:268