Import Geant4 9.4.0 source tree
This commit is contained in:
@@ -23,31 +23,46 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4Fragment.cc,v 1.22 2010/11/02 17:55:43 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Geant4 class G4Fragment
|
||||
//
|
||||
// Hadronic Process: Nuclear De-excitations
|
||||
// by V. Lara (May 1998)
|
||||
//
|
||||
// Modifications:
|
||||
// 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
|
||||
// inline to source
|
||||
// 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
|
||||
// add null pointer check.
|
||||
|
||||
#include "G4Fragment.hh"
|
||||
#include "G4HadronicException.hh"
|
||||
#include "G4HadTmpUtil.hh"
|
||||
#include "G4Gamma.hh"
|
||||
#include "G4Electron.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip>
|
||||
|
||||
G4int G4Fragment::errCount = 0;
|
||||
|
||||
// Default constructor
|
||||
G4Fragment::G4Fragment() :
|
||||
theA(0),
|
||||
theZ(0),
|
||||
theExcitationEnergy(0.0),
|
||||
theMomentum(0),
|
||||
theAngularMomentum(0),
|
||||
theGroundStateMass(0.0),
|
||||
theMomentum(G4LorentzVector(0,0,0,0)),
|
||||
theAngularMomentum(G4ThreeVector(0,0,0)),
|
||||
numberOfParticles(0),
|
||||
numberOfHoles(0),
|
||||
numberOfCharged(0),
|
||||
numberOfHoles(0),
|
||||
numberOfChargedHoles(0),
|
||||
numberOfShellElectrons(0),
|
||||
theParticleDefinition(0),
|
||||
theCreationTime(0.0)
|
||||
#ifdef PRECOMPOUND_TEST
|
||||
,theCreatorModel("No name")
|
||||
#endif
|
||||
{}
|
||||
|
||||
// Copy Constructor
|
||||
@@ -56,95 +71,87 @@ G4Fragment::G4Fragment(const G4Fragment &right)
|
||||
theA = right.theA;
|
||||
theZ = right.theZ;
|
||||
theExcitationEnergy = right.theExcitationEnergy;
|
||||
theGroundStateMass = right.theGroundStateMass;
|
||||
theMomentum = right.theMomentum;
|
||||
theAngularMomentum = right.theAngularMomentum;
|
||||
numberOfParticles = right.numberOfParticles;
|
||||
numberOfHoles = right.numberOfHoles;
|
||||
numberOfCharged = right.numberOfCharged;
|
||||
numberOfHoles = right.numberOfHoles;
|
||||
numberOfChargedHoles = right.numberOfChargedHoles;
|
||||
numberOfShellElectrons = right.numberOfShellElectrons;
|
||||
theParticleDefinition = right.theParticleDefinition;
|
||||
theCreationTime = right.theCreationTime;
|
||||
#ifdef PRECOMPOUND_TEST
|
||||
theCreatorModel = right.theCreatorModel;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
G4Fragment::~G4Fragment()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector aMomentum) :
|
||||
G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
|
||||
theA(A),
|
||||
theZ(Z),
|
||||
theMomentum(aMomentum),
|
||||
theAngularMomentum(0),
|
||||
theAngularMomentum(G4ThreeVector(0,0,0)),
|
||||
numberOfParticles(0),
|
||||
numberOfHoles(0),
|
||||
numberOfCharged(0),
|
||||
numberOfHoles(0),
|
||||
numberOfChargedHoles(0),
|
||||
numberOfShellElectrons(0),
|
||||
theParticleDefinition(0),
|
||||
theCreationTime(0.0)
|
||||
#ifdef PRECOMPOUND_TEST
|
||||
,theCreatorModel("No name")
|
||||
#endif
|
||||
{
|
||||
theExcitationEnergy = theMomentum.mag() -
|
||||
G4ParticleTable::GetParticleTable()->GetIonTable()
|
||||
->GetIonMass( G4lrint(theZ), G4lrint(theA) );
|
||||
if (theExcitationEnergy < 0.0) {
|
||||
if (theExcitationEnergy > -10.0 * eV || 0 == G4lrint(theA)) {
|
||||
theExcitationEnergy = 0.0;
|
||||
} else {
|
||||
G4cout << "A, Z, momentum, theExcitationEnergy"<<
|
||||
A<<" "<<Z<<" "<<aMomentum<<" "<<theExcitationEnergy<<G4endl;
|
||||
G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!";
|
||||
throw G4HadronicException(__FILE__, __LINE__, text);
|
||||
}
|
||||
theExcitationEnergy = 0.0;
|
||||
theGroundStateMass = 0.0;
|
||||
if(theA > 0) {
|
||||
CalculateGroundStateMass();
|
||||
CalculateExcitationEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This constructor is for initialize photons
|
||||
G4Fragment::G4Fragment(const G4LorentzVector aMomentum, G4ParticleDefinition * aParticleDefinition) :
|
||||
// This constructor is for initialize photons or electrons
|
||||
G4Fragment::G4Fragment(const G4LorentzVector& aMomentum,
|
||||
G4ParticleDefinition * aParticleDefinition) :
|
||||
theA(0),
|
||||
theZ(0),
|
||||
theMomentum(aMomentum),
|
||||
theAngularMomentum(0),
|
||||
theAngularMomentum(G4ThreeVector(0,0,0)),
|
||||
numberOfParticles(0),
|
||||
numberOfHoles(0),
|
||||
numberOfCharged(0),
|
||||
numberOfHoles(0),
|
||||
numberOfChargedHoles(0),
|
||||
numberOfShellElectrons(0),
|
||||
theParticleDefinition(aParticleDefinition),
|
||||
theCreationTime(0.0)
|
||||
#ifdef PRECOMPOUND_TEST
|
||||
,theCreatorModel("No name")
|
||||
#endif
|
||||
{
|
||||
theExcitationEnergy = CalculateExcitationEnergy(aMomentum);
|
||||
theExcitationEnergy = 0.0;
|
||||
if(aParticleDefinition != G4Gamma::Gamma() &&
|
||||
aParticleDefinition != G4Electron::Electron()) {
|
||||
G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
|
||||
+ aParticleDefinition->GetParticleName();
|
||||
throw G4HadronicException(__FILE__, __LINE__, text);
|
||||
}
|
||||
theGroundStateMass = aParticleDefinition->GetPDGMass();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const G4Fragment & G4Fragment::operator=(const G4Fragment &right)
|
||||
{
|
||||
if (this != &right) {
|
||||
theA = right.theA;
|
||||
theZ = right.theZ;
|
||||
theExcitationEnergy = right.theExcitationEnergy;
|
||||
theGroundStateMass = right.theGroundStateMass;
|
||||
theMomentum = right.theMomentum;
|
||||
theAngularMomentum = right.theAngularMomentum;
|
||||
numberOfParticles = right.numberOfParticles;
|
||||
numberOfHoles = right.numberOfHoles;
|
||||
numberOfCharged = right.numberOfCharged;
|
||||
numberOfHoles = right.numberOfHoles;
|
||||
numberOfChargedHoles = right.numberOfChargedHoles;
|
||||
numberOfShellElectrons = right.numberOfShellElectrons;
|
||||
theParticleDefinition = right.theParticleDefinition;
|
||||
theCreationTime = right.theCreationTime;
|
||||
#ifdef PRECOMPOUND_TEST
|
||||
theCreatorModel = right.theCreatorModel;
|
||||
#endif
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
G4bool G4Fragment::operator==(const G4Fragment &right) const
|
||||
{
|
||||
return (this == (G4Fragment *) &right);
|
||||
@@ -155,39 +162,48 @@ G4bool G4Fragment::operator!=(const G4Fragment &right) const
|
||||
return (this != (G4Fragment *) &right);
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
|
||||
{
|
||||
if (!theFragment) {
|
||||
out << "Fragment: null pointer ";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ios::fmtflags old_floatfield = out.flags();
|
||||
out.setf(std::ios::floatfield);
|
||||
|
||||
out
|
||||
<< "Fragment: A = " << std::setprecision(3) << theFragment->theA
|
||||
<< ", Z = " << std::setprecision(3) << theFragment->theZ ;
|
||||
out << "Fragment: A = " << std::setw(3) << theFragment->theA
|
||||
<< ", Z = " << std::setw(3) << theFragment->theZ ;
|
||||
out.setf(std::ios::scientific,std::ios::floatfield);
|
||||
out
|
||||
<< ", U = " << theFragment->GetExcitationEnergy()/MeV
|
||||
<< " MeV" << G4endl
|
||||
<< " P = ("
|
||||
<< theFragment->theMomentum.x()/MeV << ","
|
||||
<< theFragment->theMomentum.y()/MeV << ","
|
||||
<< theFragment->theMomentum.z()/MeV
|
||||
<< ") MeV E = "
|
||||
<< theFragment->theMomentum.t()/MeV << " MeV";
|
||||
|
||||
// Store user's precision setting and reset to (3) here: back-compatibility
|
||||
std::streamsize floatPrec = out.precision();
|
||||
|
||||
out << std::setprecision(3)
|
||||
<< ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
|
||||
<< " MeV" << G4endl
|
||||
<< " P = ("
|
||||
<< theFragment->theMomentum.x()/CLHEP::MeV << ","
|
||||
<< theFragment->theMomentum.y()/CLHEP::MeV << ","
|
||||
<< theFragment->theMomentum.z()/CLHEP::MeV
|
||||
<< ") MeV E = "
|
||||
<< theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
|
||||
<< G4endl;
|
||||
|
||||
// What about Angular momentum???
|
||||
|
||||
if (theFragment->GetNumberOfExcitons() != 0) {
|
||||
out << G4endl;
|
||||
out << " "
|
||||
<< "#Particles = " << theFragment->numberOfParticles
|
||||
<< ", #Holes = " << theFragment->numberOfHoles
|
||||
<< ", #Charged = " << theFragment->numberOfCharged;
|
||||
<< "#Particles= " << theFragment->numberOfParticles
|
||||
<< ", #Charged= " << theFragment->numberOfCharged
|
||||
<< ", #Holes= " << theFragment->numberOfHoles
|
||||
<< ", #ChargedHoles= " << theFragment->numberOfChargedHoles
|
||||
<< G4endl;
|
||||
}
|
||||
out.setf(old_floatfield,std::ios::floatfield);
|
||||
out.precision(floatPrec);
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
|
||||
@@ -196,43 +212,27 @@ std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double G4Fragment::CalculateExcitationEnergy(const G4LorentzVector value) const
|
||||
void G4Fragment::ExcitationEnergyWarning()
|
||||
{
|
||||
static G4int errCount(0);
|
||||
G4double theMaxGroundStateMass = theZ*G4Proton::Proton()->GetPDGMass()+
|
||||
(theA-theZ)*G4Neutron::Neutron()->GetPDGMass();
|
||||
G4double U = value.m() - std::min(theMaxGroundStateMass, GetGroundStateMass());
|
||||
if( U < 0.0 ) {
|
||||
if( U > -10.0 * eV || 0==G4lrint(theA)){
|
||||
U = 0.0;
|
||||
} else {
|
||||
if ( errCount < 10 ) {
|
||||
G4cerr << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy ="
|
||||
<<U << " for A = "<<theA<<" and Z= "<<theZ<<G4endl
|
||||
<< ", mass= " << GetGroundStateMass() << " maxMass= "<<theMaxGroundStateMass<<G4endl; ;
|
||||
errCount++;
|
||||
if (errCount == 10 ) G4cerr << "G4Fragment::CalculateExcitationEnergy():"
|
||||
<< " further warnings on negative excitation will be supressed" << G4endl;
|
||||
}
|
||||
U=0.0;
|
||||
}
|
||||
if (theExcitationEnergy < -10 * CLHEP::eV) {
|
||||
++errCount;
|
||||
if ( errCount <= 1 ) {
|
||||
G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
|
||||
G4cout << *this << G4endl;
|
||||
if( errCount == 10 ) {
|
||||
G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0 10 times!";
|
||||
throw G4HadronicException(__FILE__, __LINE__, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
return U;
|
||||
theExcitationEnergy = 0.0;
|
||||
}
|
||||
|
||||
G4ThreeVector G4Fragment::IsotropicRandom3Vector(const G4double Magnitude) const
|
||||
// Create a unit vector with a random direction isotropically distributed
|
||||
void G4Fragment::NumberOfExitationWarning(const G4String& value)
|
||||
{
|
||||
|
||||
G4double CosTheta = 1.0 - 2.0*G4UniformRand();
|
||||
G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta);
|
||||
G4double Phi = twopi*G4UniformRand();
|
||||
G4ThreeVector Vector(Magnitude*std::cos(Phi)*SinTheta,
|
||||
Magnitude*std::sin(Phi)*SinTheta,
|
||||
Magnitude*CosTheta);
|
||||
|
||||
return Vector;
|
||||
|
||||
G4cout << "G4Fragment::"<< value << " ERROR "
|
||||
<< G4endl;
|
||||
G4cout << this << G4endl;
|
||||
G4String text = "G4Fragment::G4Fragment wrong exciton number ";
|
||||
throw G4HadronicException(__FILE__, __LINE__, text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user