00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include "G4DynamicParticle.hh"
00065 #include "G4PhysicalConstants.hh"
00066 #include "G4SystemOfUnits.hh"
00067 #include "G4DecayProducts.hh"
00068 #include "G4LorentzVector.hh"
00069 #include "G4ParticleDefinition.hh"
00070 #include "G4ParticleTable.hh"
00071 #include "G4IonTable.hh"
00072 #include "G4PrimaryParticle.hh"
00073
00074 G4Allocator<G4DynamicParticle> aDynamicParticleAllocator;
00075
00076 static const G4double EnergyMomentumRelationAllowance = keV;
00077
00079 G4DynamicParticle::G4DynamicParticle():
00080 theMomentumDirection(0.0,0.0,1.0),
00081 theParticleDefinition(0),
00082 theKineticEnergy(0.0),
00083 theProperTime(0.0),
00084 theDynamicalMass(0.0),
00085 theDynamicalCharge(0.0),
00086 theDynamicalSpin(0.0),
00087 theDynamicalMagneticMoment(0.0),
00088 theElectronOccupancy(0),
00089 thePreAssignedDecayProducts(0),
00090 thePreAssignedDecayTime(-1.0),
00091 verboseLevel(1),
00092 primaryParticle(0),
00093 thePDGcode(0) {}
00094
00096
00098 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
00099 const G4ThreeVector& aMomentumDirection,
00100 G4double aKineticEnergy):
00101 theMomentumDirection(aMomentumDirection),
00102 theParticleDefinition(aParticleDefinition),
00103 theKineticEnergy(aKineticEnergy),
00104 theProperTime(0.0),
00105 theDynamicalMass(aParticleDefinition->GetPDGMass()),
00106 theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
00107 theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
00108 theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
00109 theElectronOccupancy(0),
00110 thePreAssignedDecayProducts(0),
00111 thePreAssignedDecayTime(-1.0),
00112 verboseLevel(1),
00113 primaryParticle(0),
00114 thePDGcode(0) {}
00115
00117 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
00118 const G4ThreeVector& aParticleMomentum):
00119 theParticleDefinition(aParticleDefinition),
00120 theKineticEnergy(0.0),
00121 theProperTime(0.0),
00122 theDynamicalMass(aParticleDefinition->GetPDGMass()),
00123 theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
00124 theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
00125 theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
00126 theElectronOccupancy(0),
00127 thePreAssignedDecayProducts(0),
00128 thePreAssignedDecayTime(-1.0),
00129 verboseLevel(1),
00130 primaryParticle(0),
00131 thePDGcode(0)
00132 {
00133
00134 SetMomentum(aParticleMomentum);
00135 }
00136
00138 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
00139 const G4LorentzVector &aParticleMomentum):
00140 theParticleDefinition(aParticleDefinition),
00141 theKineticEnergy(0.0),
00142 theProperTime(0.0),
00143 theDynamicalMass(aParticleDefinition->GetPDGMass()),
00144 theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
00145 theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
00146 theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
00147 theElectronOccupancy(0),
00148 thePreAssignedDecayProducts(0),
00149 thePreAssignedDecayTime(-1.0),
00150 verboseLevel(1),
00151 primaryParticle(0),
00152 thePDGcode(0)
00153 {
00154
00155 Set4Momentum(aParticleMomentum);
00156 }
00157
00158 G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
00159 G4double totalEnergy,
00160 const G4ThreeVector &aParticleMomentum):
00161 theParticleDefinition(aParticleDefinition),
00162 theKineticEnergy(0.0),
00163 theProperTime(0.0),
00164 theDynamicalMass(aParticleDefinition->GetPDGMass()),
00165 theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
00166 theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
00167 theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
00168 theElectronOccupancy(0),
00169 thePreAssignedDecayProducts(0),
00170 thePreAssignedDecayTime(-1.0),
00171 verboseLevel(1),
00172 primaryParticle(0),
00173 thePDGcode(0)
00174 {
00175
00176 G4double pModule2 = aParticleMomentum.mag2();
00177 if (pModule2>0.0) {
00178 G4double mass2 = totalEnergy*totalEnergy - pModule2;
00179 if(mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
00180 theDynamicalMass = 0.;
00181 SetMomentumDirection(aParticleMomentum.unit());
00182 SetKineticEnergy(totalEnergy);
00183 } else {
00184 theDynamicalMass = std::sqrt(mass2);
00185 SetMomentum(aParticleMomentum);
00186 }
00187 } else {
00188 SetMomentumDirection(1.0,0.0,0.0);
00189 SetKineticEnergy(0.0);
00190 }
00191 }
00192
00194 G4DynamicParticle::G4DynamicParticle(const G4DynamicParticle &right):
00195 theMomentumDirection(right.theMomentumDirection),
00196 theParticleDefinition(right.theParticleDefinition),
00197 thePolarization(right.thePolarization),
00198 theKineticEnergy(right.theKineticEnergy),
00199 theProperTime(0.0),
00200 theDynamicalMass(right.theDynamicalMass),
00201 theDynamicalCharge(right.theDynamicalCharge),
00202 theDynamicalSpin(right.theDynamicalSpin),
00203 theDynamicalMagneticMoment(right.theDynamicalMagneticMoment),
00204 theElectronOccupancy(0),
00205 thePreAssignedDecayProducts(0),
00206 thePreAssignedDecayTime(-1.0),
00207 verboseLevel(right.verboseLevel),
00208 primaryParticle(right.primaryParticle),
00209 thePDGcode(right.thePDGcode)
00210 {
00211 if (right.theElectronOccupancy != 0) {
00212 theElectronOccupancy =
00213 new G4ElectronOccupancy(*right.theElectronOccupancy);
00214 }
00215 }
00216
00218
00220 G4DynamicParticle::~G4DynamicParticle() {
00221
00222
00223 if (thePreAssignedDecayProducts != 0) delete thePreAssignedDecayProducts;
00224 thePreAssignedDecayProducts = 0;
00225
00226 if (theElectronOccupancy != 0) delete theElectronOccupancy;
00227 theElectronOccupancy =0;
00228 }
00229
00230
00232
00234 G4DynamicParticle & G4DynamicParticle::operator=(const G4DynamicParticle &right)
00235 {
00236 if (this != &right) {
00237 theMomentumDirection = right.theMomentumDirection;
00238 theParticleDefinition = right.theParticleDefinition;
00239 thePolarization = right.thePolarization;
00240 theKineticEnergy = right.theKineticEnergy;
00241 theProperTime = right.theProperTime;
00242
00243 theDynamicalMass = right.theDynamicalMass;
00244 theDynamicalCharge = right.theDynamicalCharge;
00245 theDynamicalSpin = right.theDynamicalSpin;
00246 theDynamicalMagneticMoment = right.theDynamicalMagneticMoment;
00247
00248 if (theElectronOccupancy != 0) delete theElectronOccupancy;
00249 if (right.theElectronOccupancy != 0){
00250 theElectronOccupancy =
00251 new G4ElectronOccupancy(*right.theElectronOccupancy);
00252 } else {
00253 theElectronOccupancy = 0;
00254 }
00255
00256
00257 thePreAssignedDecayProducts = 0;
00258 thePreAssignedDecayTime = -1.0;
00259
00260 verboseLevel = right.verboseLevel;
00261
00262
00263
00264
00265 thePDGcode = right.thePDGcode;
00266 }
00267 return *this;
00268 }
00269
00271 void G4DynamicParticle::SetDefinition(const G4ParticleDefinition * aParticleDefinition)
00272 {
00273
00274 if (thePreAssignedDecayProducts != 0) {
00275 #ifdef G4VERBOSE
00276 if (verboseLevel>0) {
00277 G4cerr << " G4DynamicParticle::SetDefinition()::"
00278 << "!!! Pre-assigned decay products is attached !!!! " << G4endl;
00279 G4cerr << "!!! New Definition is " << aParticleDefinition->GetParticleName()
00280 << " !!! " << G4endl;
00281 G4cerr << "!!! Pre-assigned decay products will be deleted !!!! " << G4endl;
00282 }
00283 #endif
00284 delete thePreAssignedDecayProducts;
00285 }
00286 thePreAssignedDecayProducts = 0;
00287
00288 theParticleDefinition = aParticleDefinition;
00289
00290
00291 theDynamicalMass = theParticleDefinition->GetPDGMass();
00292 theDynamicalCharge = theParticleDefinition->GetPDGCharge();
00293 theDynamicalSpin = theParticleDefinition->GetPDGSpin();
00294 theDynamicalMagneticMoment = theParticleDefinition->GetPDGMagneticMoment();
00295
00296
00297 if (theElectronOccupancy != 0) delete theElectronOccupancy;
00298 theElectronOccupancy =0;
00299
00300
00301 }
00302
00304 G4int G4DynamicParticle::operator==(const G4DynamicParticle &right) const
00305 {
00306 return (this == (G4DynamicParticle *) &right);
00307 }
00308
00310 G4int G4DynamicParticle::operator!=(const G4DynamicParticle &right) const
00311 {
00312 return (this != (G4DynamicParticle *) &right);
00313 }
00314
00315
00316
00318
00320 void G4DynamicParticle::AllocateElectronOccupancy()
00321 {
00322 const G4ParticleDefinition* particle = GetDefinition();
00323
00324 if (G4IonTable::IsIon(particle)) {
00325
00326 theElectronOccupancy = new G4ElectronOccupancy();
00327
00328 } else {
00329 theElectronOccupancy = 0;
00330
00331 }
00332 }
00333
00335
00337 void G4DynamicParticle::SetMomentum(const G4ThreeVector &momentum)
00338 {
00339 G4double pModule2 = momentum.mag2();
00340 if (pModule2>0.0) {
00341 G4double mass = theDynamicalMass;
00342 SetMomentumDirection(momentum.unit());
00343 SetKineticEnergy(std::sqrt(pModule2 + mass*mass)-mass);
00344 } else {
00345 SetMomentumDirection(1.0,0.0,0.0);
00346 SetKineticEnergy(0.0);
00347 }
00348 }
00349
00351 void G4DynamicParticle::Set4Momentum(const G4LorentzVector &momentum )
00352 {
00353 G4double pModule2 = momentum.vect().mag2();
00354 if (pModule2>0.0) {
00355 SetMomentumDirection(momentum.vect().unit());
00356 G4double totalenergy = momentum.t();
00357 G4double mass2 = totalenergy*totalenergy - pModule2;
00358 if(mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
00359 theDynamicalMass = 0.;
00360 SetKineticEnergy(totalenergy);
00361 } else {
00362 theDynamicalMass = std::sqrt(mass2);
00363 SetKineticEnergy(totalenergy-theDynamicalMass);
00364 }
00365 } else {
00366 SetMomentumDirection(1.0,0.0,0.0);
00367 SetKineticEnergy(0.0);
00368 }
00369 }
00370
00371
00373
00375 #ifdef G4VERBOSE
00376 void G4DynamicParticle::DumpInfo(G4int mode) const
00377 {
00378 if (theParticleDefinition == 0) {
00379 G4cout << " G4DynamicParticle::DumpInfo():: !!!Particle type not defined !!!! " << G4endl;
00380 } else {
00381 G4cout << " Particle type - " << theParticleDefinition->GetParticleName() << G4endl
00382 << " mass: " << GetMass()/GeV << "[GeV]" <<G4endl
00383 << " charge: " << GetCharge()/eplus << "[e]" <<G4endl
00384 << " Direction x: " << GetMomentumDirection().x() << ", y: "
00385 << GetMomentumDirection().y() << ", z: "
00386 << GetMomentumDirection().z() << G4endl
00387 << " Total Momentum = " << GetTotalMomentum() /GeV << "[GeV]" << G4endl
00388 << " Momentum: " << GetMomentum().x() /GeV << "[GeV]" << ", y: "
00389 << GetMomentum().y() /GeV << "[GeV]" << ", z: "
00390 << GetMomentum().z() /GeV << "[GeV]" << G4endl
00391 << " Total Energy = " << GetTotalEnergy()/GeV << "[GeV]" << G4endl
00392 << " Kinetic Energy = " << GetKineticEnergy() /GeV << "[GeV]" << G4endl
00393 << " MagneticMoment [MeV/T]: " << GetMagneticMoment()/MeV*tesla << G4endl
00394 << " ProperTime = " << GetProperTime() /ns << "[ns]" << G4endl;
00395
00396 if (mode>0) {
00397 if( theElectronOccupancy != 0) {
00398 theElectronOccupancy->DumpInfo();
00399 }
00400 }
00401 }
00402 }
00403 #else
00404 void G4DynamicParticle::DumpInfo(G4int) const
00405 {
00406 return;
00407 }
00408 #endif
00409
00411 G4double G4DynamicParticle::GetElectronMass() const
00412 {
00413 static G4double electronMass = 0.0;
00414
00415
00416 if (electronMass<=0.0) {
00417 G4ParticleDefinition* electron = G4ParticleTable::GetParticleTable()->FindParticle("e-");
00418 if (electron == 0) {
00419 G4Exception("G4DynamicParticle::GetElectronMass()","PART021",
00420 FatalException,"G4DynamicParticle: G4Electron is not defined !!");
00421 }
00422 electronMass = electron->GetPDGMass();
00423 }
00424
00425 return electronMass;
00426 }