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 #define INCLXX_IN_GEANT4_MODE 1
00034
00035 #include "globals.hh"
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "G4INCLParticle.hh"
00045 #include "G4INCLParticleTable.hh"
00046
00047 namespace G4INCL {
00048
00049 long Particle::nextID = 1;
00050
00051 Particle::Particle()
00052 : theZ(0), theA(0),
00053 theParticipantType(TargetSpectator),
00054 theType(UnknownParticle),
00055 theEnergy(0.0),
00056 thePropagationEnergy(&theEnergy),
00057 theFrozenEnergy(theEnergy),
00058 theMomentum(ThreeVector(0.,0.,0.)),
00059 thePropagationMomentum(&theMomentum),
00060 theFrozenMomentum(theMomentum),
00061 thePosition(ThreeVector(0.,0.,0.)),
00062 nCollisions(0),
00063 nDecays(0),
00064 thePotentialEnergy(0.0),
00065 theHelicity(0.0),
00066 emissionTime(0.0),
00067 outOfWell(false),
00068 theMass(0.)
00069 {
00070 ID = nextID;
00071 nextID++;
00072 }
00073
00074 Particle::Particle(ParticleType t, G4double energy,
00075 ThreeVector momentum, ThreeVector position)
00076 : theEnergy(energy),
00077 thePropagationEnergy(&theEnergy),
00078 theFrozenEnergy(theEnergy),
00079 theMomentum(momentum),
00080 thePropagationMomentum(&theMomentum),
00081 theFrozenMomentum(theMomentum),
00082 thePosition(position),
00083 nCollisions(0), nDecays(0),
00084 thePotentialEnergy(0.), theHelicity(0.0),
00085 emissionTime(0.0), outOfWell(false)
00086 {
00087 theParticipantType = TargetSpectator;
00088 ID = nextID;
00089 nextID++;
00090 if(theEnergy <= 0.0) {
00091 WARN("Particle with energy " << theEnergy << " created." << std::endl);
00092 }
00093 setType(t);
00094 setMass(getInvariantMass());
00095 }
00096
00097 Particle::Particle(ParticleType t,
00098 ThreeVector momentum, ThreeVector position)
00099 : thePropagationEnergy(&theEnergy),
00100 theMomentum(momentum),
00101 thePropagationMomentum(&theMomentum),
00102 theFrozenMomentum(theMomentum),
00103 thePosition(position),
00104 nCollisions(0), nDecays(0),
00105 thePotentialEnergy(0.), theHelicity(0.0),
00106 emissionTime(0.0), outOfWell(false)
00107 {
00108 theParticipantType = TargetSpectator;
00109 ID = nextID;
00110 nextID++;
00111 setType(t);
00112 if( isResonance() ) {
00113 ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
00114 }
00115 G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
00116 theEnergy = energy;
00117 theFrozenEnergy = theEnergy;
00118 }
00119
00120 const ThreeVector &Particle::adjustMomentumFromEnergy() {
00121 const G4double p2 = theMomentum.mag2();
00122 G4double newp2 = theEnergy*theEnergy - theMass*theMass;
00123 if( newp2<0.0 ) {
00124 ERROR("Particle has E^2 < m^2." << std::endl << print());
00125 newp2 = 0.0;
00126 theEnergy = theMass;
00127 }
00128
00129 theMomentum *= std::sqrt(newp2/p2);
00130 return theMomentum;
00131 }
00132
00133 G4double Particle::adjustEnergyFromMomentum() {
00134 theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
00135 return theEnergy;
00136 }
00137 }