[819] | 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 | // |
---|
[1315] | 26 | // $Id: G4Fragment.cc,v 1.16 2010/05/18 18:52:07 vnivanch Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
[819] | 28 | // |
---|
[1315] | 29 | //--------------------------------------------------------------------- |
---|
[819] | 30 | // |
---|
[1315] | 31 | // Geant4 class G4Fragment |
---|
| 32 | // |
---|
[819] | 33 | // Hadronic Process: Nuclear De-excitations |
---|
| 34 | // by V. Lara (May 1998) |
---|
[1315] | 35 | // |
---|
| 36 | // Modifications: |
---|
| 37 | // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from |
---|
| 38 | // inline to source |
---|
| 39 | // |
---|
[819] | 40 | |
---|
| 41 | #include "G4Fragment.hh" |
---|
| 42 | #include "G4HadronicException.hh" |
---|
| 43 | #include "G4HadTmpUtil.hh" |
---|
[1315] | 44 | #include "G4Gamma.hh" |
---|
| 45 | #include "G4Electron.hh" |
---|
[819] | 46 | |
---|
[1315] | 47 | G4int G4Fragment::errCount = 0; |
---|
[819] | 48 | |
---|
| 49 | // Default constructor |
---|
| 50 | G4Fragment::G4Fragment() : |
---|
| 51 | theA(0), |
---|
| 52 | theZ(0), |
---|
| 53 | theExcitationEnergy(0.0), |
---|
[1315] | 54 | theGroundStateMass(0.0), |
---|
[819] | 55 | theMomentum(0), |
---|
| 56 | theAngularMomentum(0), |
---|
| 57 | numberOfParticles(0), |
---|
| 58 | numberOfHoles(0), |
---|
| 59 | numberOfCharged(0), |
---|
| 60 | theParticleDefinition(0), |
---|
| 61 | theCreationTime(0.0) |
---|
| 62 | #ifdef PRECOMPOUND_TEST |
---|
| 63 | ,theCreatorModel("No name") |
---|
| 64 | #endif |
---|
| 65 | {} |
---|
| 66 | |
---|
| 67 | // Copy Constructor |
---|
| 68 | G4Fragment::G4Fragment(const G4Fragment &right) |
---|
| 69 | { |
---|
| 70 | theA = right.theA; |
---|
| 71 | theZ = right.theZ; |
---|
| 72 | theExcitationEnergy = right.theExcitationEnergy; |
---|
[1315] | 73 | theGroundStateMass = right.theGroundStateMass; |
---|
[819] | 74 | theMomentum = right.theMomentum; |
---|
| 75 | theAngularMomentum = right.theAngularMomentum; |
---|
| 76 | numberOfParticles = right.numberOfParticles; |
---|
| 77 | numberOfHoles = right.numberOfHoles; |
---|
| 78 | numberOfCharged = right.numberOfCharged; |
---|
| 79 | theParticleDefinition = right.theParticleDefinition; |
---|
| 80 | theCreationTime = right.theCreationTime; |
---|
| 81 | #ifdef PRECOMPOUND_TEST |
---|
| 82 | theCreatorModel = right.theCreatorModel; |
---|
| 83 | #endif |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | G4Fragment::~G4Fragment() |
---|
[1315] | 87 | {} |
---|
[819] | 88 | |
---|
[1315] | 89 | G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector& aMomentum) : |
---|
[819] | 90 | theA(A), |
---|
| 91 | theZ(Z), |
---|
| 92 | theMomentum(aMomentum), |
---|
| 93 | theAngularMomentum(0), |
---|
| 94 | numberOfParticles(0), |
---|
| 95 | numberOfHoles(0), |
---|
| 96 | numberOfCharged(0), |
---|
| 97 | theParticleDefinition(0), |
---|
| 98 | theCreationTime(0.0) |
---|
| 99 | #ifdef PRECOMPOUND_TEST |
---|
| 100 | ,theCreatorModel("No name") |
---|
| 101 | #endif |
---|
| 102 | { |
---|
[1315] | 103 | theExcitationEnergy = 0.0; |
---|
| 104 | theGroundStateMass = 0.0; |
---|
| 105 | if(theA > 0) { |
---|
| 106 | CalculateGroundStateMass(); |
---|
| 107 | CalculateExcitationEnergy(); |
---|
| 108 | } |
---|
| 109 | /* |
---|
[819] | 110 | theExcitationEnergy = theMomentum.mag() - |
---|
| 111 | G4ParticleTable::GetParticleTable()->GetIonTable() |
---|
| 112 | ->GetIonMass( G4lrint(theZ), G4lrint(theA) ); |
---|
| 113 | if (theExcitationEnergy < 0.0) { |
---|
| 114 | if (theExcitationEnergy > -10.0 * eV || 0 == G4lrint(theA)) { |
---|
| 115 | theExcitationEnergy = 0.0; |
---|
| 116 | } else { |
---|
| 117 | G4cout << "A, Z, momentum, theExcitationEnergy"<< |
---|
| 118 | A<<" "<<Z<<" "<<aMomentum<<" "<<theExcitationEnergy<<G4endl; |
---|
| 119 | G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; |
---|
| 120 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
| 121 | } |
---|
| 122 | } |
---|
[1315] | 123 | */ |
---|
[819] | 124 | } |
---|
| 125 | |
---|
| 126 | |
---|
[1315] | 127 | // This constructor is for initialize photons or electrons |
---|
| 128 | G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, |
---|
| 129 | G4ParticleDefinition * aParticleDefinition) : |
---|
[819] | 130 | theA(0), |
---|
| 131 | theZ(0), |
---|
| 132 | theMomentum(aMomentum), |
---|
| 133 | theAngularMomentum(0), |
---|
| 134 | numberOfParticles(0), |
---|
| 135 | numberOfHoles(0), |
---|
| 136 | numberOfCharged(0), |
---|
| 137 | theParticleDefinition(aParticleDefinition), |
---|
| 138 | theCreationTime(0.0) |
---|
| 139 | #ifdef PRECOMPOUND_TEST |
---|
| 140 | ,theCreatorModel("No name") |
---|
| 141 | #endif |
---|
| 142 | { |
---|
[1315] | 143 | theExcitationEnergy = 0.0; |
---|
| 144 | if(aParticleDefinition != G4Gamma::Gamma() && |
---|
| 145 | aParticleDefinition != G4Electron::Electron()) { |
---|
| 146 | G4String text = "G4Fragment::G4Fragment constructor for gamma used for " |
---|
| 147 | + aParticleDefinition->GetParticleName(); |
---|
| 148 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
| 149 | } |
---|
| 150 | theGroundStateMass = aParticleDefinition->GetPDGMass(); |
---|
[819] | 151 | } |
---|
| 152 | |
---|
| 153 | const G4Fragment & G4Fragment::operator=(const G4Fragment &right) |
---|
| 154 | { |
---|
| 155 | if (this != &right) { |
---|
| 156 | theA = right.theA; |
---|
| 157 | theZ = right.theZ; |
---|
| 158 | theExcitationEnergy = right.theExcitationEnergy; |
---|
[1315] | 159 | theGroundStateMass = right.theGroundStateMass; |
---|
[819] | 160 | theMomentum = right.theMomentum; |
---|
| 161 | theAngularMomentum = right.theAngularMomentum; |
---|
| 162 | numberOfParticles = right.numberOfParticles; |
---|
| 163 | numberOfHoles = right.numberOfHoles; |
---|
| 164 | numberOfCharged = right.numberOfCharged; |
---|
| 165 | theParticleDefinition = right.theParticleDefinition; |
---|
| 166 | theCreationTime = right.theCreationTime; |
---|
| 167 | #ifdef PRECOMPOUND_TEST |
---|
| 168 | theCreatorModel = right.theCreatorModel; |
---|
| 169 | #endif |
---|
| 170 | } |
---|
| 171 | return *this; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | G4bool G4Fragment::operator==(const G4Fragment &right) const |
---|
| 175 | { |
---|
| 176 | return (this == (G4Fragment *) &right); |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | G4bool G4Fragment::operator!=(const G4Fragment &right) const |
---|
| 180 | { |
---|
| 181 | return (this != (G4Fragment *) &right); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment) |
---|
| 185 | { |
---|
| 186 | std::ios::fmtflags old_floatfield = out.flags(); |
---|
| 187 | out.setf(std::ios::floatfield); |
---|
| 188 | |
---|
| 189 | out |
---|
| 190 | << "Fragment: A = " << std::setprecision(3) << theFragment->theA |
---|
| 191 | << ", Z = " << std::setprecision(3) << theFragment->theZ ; |
---|
| 192 | out.setf(std::ios::scientific,std::ios::floatfield); |
---|
| 193 | out |
---|
| 194 | << ", U = " << theFragment->GetExcitationEnergy()/MeV |
---|
| 195 | << " MeV" << G4endl |
---|
| 196 | << " P = (" |
---|
| 197 | << theFragment->theMomentum.x()/MeV << "," |
---|
| 198 | << theFragment->theMomentum.y()/MeV << "," |
---|
| 199 | << theFragment->theMomentum.z()/MeV |
---|
| 200 | << ") MeV E = " |
---|
| 201 | << theFragment->theMomentum.t()/MeV << " MeV"; |
---|
| 202 | |
---|
| 203 | // What about Angular momentum??? |
---|
| 204 | |
---|
| 205 | if (theFragment->GetNumberOfExcitons() != 0) { |
---|
| 206 | out << G4endl; |
---|
| 207 | out << " " |
---|
| 208 | << "#Particles = " << theFragment->numberOfParticles |
---|
| 209 | << ", #Holes = " << theFragment->numberOfHoles |
---|
| 210 | << ", #Charged = " << theFragment->numberOfCharged; |
---|
| 211 | } |
---|
| 212 | out.setf(old_floatfield,std::ios::floatfield); |
---|
| 213 | |
---|
| 214 | return out; |
---|
| 215 | |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment) |
---|
| 219 | { |
---|
| 220 | out << &theFragment; |
---|
| 221 | return out; |
---|
| 222 | } |
---|
| 223 | |
---|
[1315] | 224 | void G4Fragment::ExcitationEnegryWarning() |
---|
[819] | 225 | { |
---|
[1315] | 226 | if (theExcitationEnergy < -10.0 * eV) { |
---|
| 227 | ++errCount; |
---|
| 228 | if ( errCount <= 10 ) { |
---|
| 229 | G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = " |
---|
| 230 | << theExcitationEnergy/MeV << " MeV for A = " |
---|
| 231 | <<theA << " and Z= " << theZ << G4endl; |
---|
| 232 | if( errCount == 10 ) { |
---|
| 233 | G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!"; |
---|
| 234 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
| 235 | } |
---|
| 236 | } |
---|
[819] | 237 | } |
---|
[1315] | 238 | theExcitationEnergy = 0.0; |
---|
[819] | 239 | } |
---|
| 240 | |
---|
| 241 | G4ThreeVector G4Fragment::IsotropicRandom3Vector(const G4double Magnitude) const |
---|
| 242 | // Create a unit vector with a random direction isotropically distributed |
---|
| 243 | { |
---|
| 244 | G4double CosTheta = 1.0 - 2.0*G4UniformRand(); |
---|
| 245 | G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta); |
---|
| 246 | G4double Phi = twopi*G4UniformRand(); |
---|
| 247 | G4ThreeVector Vector(Magnitude*std::cos(Phi)*SinTheta, |
---|
| 248 | Magnitude*std::sin(Phi)*SinTheta, |
---|
| 249 | Magnitude*CosTheta); |
---|
| 250 | |
---|
[1315] | 251 | return Vector; |
---|
[819] | 252 | } |
---|
[1315] | 253 | |
---|
| 254 | void G4Fragment::SetExcitationEnergy(const G4double ) |
---|
| 255 | { |
---|
| 256 | // theExcitationEnergy = value; |
---|
| 257 | G4cout << "Warning: G4Fragment::SetExcitationEnergy() is a dummy method. Please, avoid to use it." << G4endl; |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | #ifdef PRECOMPOUND_TEST |
---|
| 261 | G4String G4Fragment::GetCreatorModel() const |
---|
| 262 | { |
---|
| 263 | return theCreatorModel; |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | void G4Fragment::SetCreatorModel(const G4String & aModel) |
---|
| 267 | { |
---|
| 268 | theCreatorModel = aModel; |
---|
| 269 | } |
---|
| 270 | #endif |
---|