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 #include "G4Fragment.hh"
00042 #include "G4HadronicException.hh"
00043 #include "G4Gamma.hh"
00044 #include "G4Electron.hh"
00045 #include "G4ios.hh"
00046 #include <iomanip>
00047
00048 G4int G4Fragment::errCount = 0;
00049
00050
00051 G4Fragment::G4Fragment() :
00052 theA(0),
00053 theZ(0),
00054 theExcitationEnergy(0.0),
00055 theGroundStateMass(0.0),
00056 theMomentum(G4LorentzVector(0,0,0,0)),
00057 theAngularMomentum(G4ThreeVector(0,0,0)),
00058 numberOfParticles(0),
00059 numberOfCharged(0),
00060 numberOfHoles(0),
00061 numberOfChargedHoles(0),
00062 numberOfShellElectrons(0),
00063 theParticleDefinition(0),
00064 theCreationTime(0.0),
00065 isStable(true)
00066 {}
00067
00068
00069 G4Fragment::G4Fragment(const G4Fragment &right)
00070 {
00071 theA = right.theA;
00072 theZ = right.theZ;
00073 theExcitationEnergy = right.theExcitationEnergy;
00074 theGroundStateMass = right.theGroundStateMass;
00075 theMomentum = right.theMomentum;
00076 theAngularMomentum = right.theAngularMomentum;
00077 numberOfParticles = right.numberOfParticles;
00078 numberOfCharged = right.numberOfCharged;
00079 numberOfHoles = right.numberOfHoles;
00080 numberOfChargedHoles = right.numberOfChargedHoles;
00081 numberOfShellElectrons = right.numberOfShellElectrons;
00082 theParticleDefinition = right.theParticleDefinition;
00083 theCreationTime = right.theCreationTime;
00084 isStable = right.isStable;
00085 }
00086
00087 G4Fragment::~G4Fragment()
00088 {}
00089
00090 G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
00091 theA(A),
00092 theZ(Z),
00093 theMomentum(aMomentum),
00094 theAngularMomentum(G4ThreeVector(0,0,0)),
00095 numberOfParticles(0),
00096 numberOfCharged(0),
00097 numberOfHoles(0),
00098 numberOfChargedHoles(0),
00099 numberOfShellElectrons(0),
00100 theParticleDefinition(0),
00101 theCreationTime(0.0),
00102 isStable(true)
00103 {
00104 theExcitationEnergy = 0.0;
00105 theGroundStateMass = 0.0;
00106 if(theA > 0) {
00107 CalculateGroundStateMass();
00108 CalculateExcitationEnergy();
00109
00110
00111
00112 if(theExcitationEnergy > 0.0) { isStable = false; }
00113 }
00114 }
00115
00116
00117 G4Fragment::G4Fragment(const G4LorentzVector& aMomentum,
00118 G4ParticleDefinition * aParticleDefinition) :
00119 theA(0),
00120 theZ(0),
00121 theMomentum(aMomentum),
00122 theAngularMomentum(G4ThreeVector(0,0,0)),
00123 numberOfParticles(0),
00124 numberOfCharged(0),
00125 numberOfHoles(0),
00126 numberOfChargedHoles(0),
00127 numberOfShellElectrons(0),
00128 theParticleDefinition(aParticleDefinition),
00129 theCreationTime(0.0),
00130 isStable(true)
00131 {
00132 theExcitationEnergy = 0.0;
00133 if(aParticleDefinition != G4Gamma::Gamma() &&
00134 aParticleDefinition != G4Electron::Electron()) {
00135 G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
00136 + aParticleDefinition->GetParticleName();
00137 throw G4HadronicException(__FILE__, __LINE__, text);
00138 }
00139 theGroundStateMass = aParticleDefinition->GetPDGMass();
00140 }
00141
00142 G4Fragment & G4Fragment::operator=(const G4Fragment &right)
00143 {
00144 if (this != &right) {
00145 theA = right.theA;
00146 theZ = right.theZ;
00147 theExcitationEnergy = right.theExcitationEnergy;
00148 theGroundStateMass = right.theGroundStateMass;
00149 theMomentum = right.theMomentum;
00150 theAngularMomentum = right.theAngularMomentum;
00151 numberOfParticles = right.numberOfParticles;
00152 numberOfCharged = right.numberOfCharged;
00153 numberOfHoles = right.numberOfHoles;
00154 numberOfChargedHoles = right.numberOfChargedHoles;
00155 numberOfShellElectrons = right.numberOfShellElectrons;
00156 theParticleDefinition = right.theParticleDefinition;
00157 theCreationTime = right.theCreationTime;
00158 isStable = right.isStable;
00159 }
00160 return *this;
00161 }
00162
00163 G4bool G4Fragment::operator==(const G4Fragment &right) const
00164 {
00165 return (this == (G4Fragment *) &right);
00166 }
00167
00168 G4bool G4Fragment::operator!=(const G4Fragment &right) const
00169 {
00170 return (this != (G4Fragment *) &right);
00171 }
00172
00173 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
00174 {
00175 if (!theFragment) {
00176 out << "Fragment: null pointer ";
00177 return out;
00178 }
00179
00180 std::ios::fmtflags old_floatfield = out.flags();
00181 out.setf(std::ios::floatfield);
00182
00183 out << "Fragment: A = " << std::setw(3) << theFragment->theA
00184 << ", Z = " << std::setw(3) << theFragment->theZ ;
00185 out.setf(std::ios::scientific,std::ios::floatfield);
00186
00187
00188 std::streamsize floatPrec = out.precision();
00189
00190 out << std::setprecision(3)
00191 << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
00192 << " MeV IsStable= " << theFragment->IsStable() << G4endl
00193 << " P = ("
00194 << theFragment->theMomentum.x()/CLHEP::MeV << ","
00195 << theFragment->theMomentum.y()/CLHEP::MeV << ","
00196 << theFragment->theMomentum.z()/CLHEP::MeV
00197 << ") MeV E = "
00198 << theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
00199 << G4endl;
00200
00201
00202
00203 if (theFragment->GetNumberOfExcitons() != 0) {
00204 out << " "
00205 << "#Particles= " << theFragment->numberOfParticles
00206 << ", #Charged= " << theFragment->numberOfCharged
00207 << ", #Holes= " << theFragment->numberOfHoles
00208 << ", #ChargedHoles= " << theFragment->numberOfChargedHoles
00209 << G4endl;
00210 }
00211 out.setf(old_floatfield,std::ios::floatfield);
00212 out.precision(floatPrec);
00213
00214 return out;
00215 }
00216
00217 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
00218 {
00219 out << &theFragment;
00220 return out;
00221 }
00222
00223 void G4Fragment::ExcitationEnergyWarning()
00224 {
00225 if (theExcitationEnergy < -10 * CLHEP::eV) {
00226 ++errCount;
00227 if ( errCount <= 1 ) {
00228 G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
00229 G4cout << *this << G4endl;
00230 if( errCount == 10 ) {
00231 G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0 10 times!";
00232 throw G4HadronicException(__FILE__, __LINE__, text);
00233 }
00234 }
00235 }
00236 theExcitationEnergy = 0.0;
00237 }
00238
00239 void G4Fragment::NumberOfExitationWarning(const G4String& value)
00240 {
00241 G4cout << "G4Fragment::"<< value << " ERROR "
00242 << G4endl;
00243 G4cout << this << G4endl;
00244 G4String text = "G4Fragment::G4Fragment wrong exciton number ";
00245 throw G4HadronicException(__FILE__, __LINE__, text);
00246 }