Import Geant4 10.3.1 source tree

This commit is contained in:
Gabriele Cosmo
2017-02-28 16:16:20 +01:00
parent a3452e42ac
commit 4597adb7c4
267 changed files with 14761 additions and 24650 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Fragment.cc 97799 2016-06-13 12:13:11Z gcosmo $
// $Id: G4Fragment.cc 102724 2017-02-20 13:00:39Z gcosmo $
//
//---------------------------------------------------------------------
//
@@ -43,9 +43,8 @@
#include "G4ios.hh"
#include <iomanip>
//#define debug_G4Fragment
G4ThreadLocal G4Allocator<G4Fragment> *pFragmentAllocator = nullptr;
const G4double G4Fragment::minFragExcitation = 10.*CLHEP::eV;
// Default constructor
G4Fragment::G4Fragment() :
@@ -61,6 +60,7 @@ G4Fragment::G4Fragment() :
numberOfHoles(0),
numberOfChargedHoles(0),
numberOfShellElectrons(0),
xLevel(0),
theParticleDefinition(nullptr),
spin(0.0),
theCreationTime(0.0)
@@ -80,6 +80,7 @@ G4Fragment::G4Fragment(const G4Fragment &right) :
numberOfHoles(right.numberOfHoles),
numberOfChargedHoles(right.numberOfChargedHoles),
numberOfShellElectrons(right.numberOfShellElectrons),
xLevel(right.xLevel),
theParticleDefinition(right.theParticleDefinition),
spin(right.spin),
theCreationTime(right.theCreationTime)
@@ -92,6 +93,7 @@ G4Fragment::G4Fragment(const G4Fragment &right) :
G4Fragment::~G4Fragment()
{
delete thePolarization;
thePolarization = nullptr;
}
G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
@@ -107,6 +109,7 @@ G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
numberOfHoles(0),
numberOfChargedHoles(0),
numberOfShellElectrons(0),
xLevel(0),
theParticleDefinition(nullptr),
spin(0.0),
theCreationTime(0.0)
@@ -131,6 +134,7 @@ G4Fragment::G4Fragment(const G4LorentzVector& aMomentum,
numberOfHoles(0),
numberOfChargedHoles(0),
numberOfShellElectrons(0),
xLevel(0),
theParticleDefinition(aParticleDefinition),
spin(0.0),
theCreationTime(0.0)
@@ -163,6 +167,7 @@ G4Fragment & G4Fragment::operator=(const G4Fragment &right)
numberOfHoles = right.numberOfHoles;
numberOfChargedHoles = right.numberOfChargedHoles;
numberOfShellElectrons = right.numberOfShellElectrons;
xLevel = right.xLevel;
theParticleDefinition = right.theParticleDefinition;
spin = right.spin;
theCreationTime = right.theCreationTime;
@@ -214,6 +219,9 @@ std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
<< ") MeV E = "
<< theFragment->GetMomentum().t()/CLHEP::MeV << " MeV"
<< G4endl;
out << " #spin= " << theFragment->GetSpin()
<< " #floatLevelNo= " << theFragment->GetFloatingLevelNumber();
if(theFragment->GetNuclearPolarization()) {
out << theFragment->GetNuclearPolarization();
@@ -224,10 +232,9 @@ std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
<< "#Particles= " << theFragment->GetNumberOfParticles()
<< ", #Charged= " << theFragment->GetNumberOfCharged()
<< ", #Holes= " << theFragment->GetNumberOfHoles()
<< ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles()
<< ", #spin= " << theFragment->GetSpin()
<< G4endl;
<< ", #ChargedHoles= " << theFragment->GetNumberOfChargedHoles();
}
out << G4endl;
out.setf(old_floatfield,std::ios::floatfield);
out.precision(floatPrec);
@@ -242,22 +249,10 @@ std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
void G4Fragment::ExcitationEnergyWarning()
{
const G4double exclimit = -10*CLHEP::eV;
if (theExcitationEnergy < exclimit) {
#ifdef G4VERBOSE
G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
G4cout << *this << G4endl;
G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
G4cout << *this << G4endl;
#endif
#ifdef debug_G4Fragment
G4ExceptionDescription ed;
ed << *this << G4endl;
G4Exception("G4Fragment::ExcitationEnergyWarning()", "had777",
FatalException,ed);
#endif
}
theExcitationEnergy = 0.0;
}
void G4Fragment::NumberOfExitationWarning(const G4String& value)
@@ -269,7 +264,7 @@ void G4Fragment::NumberOfExitationWarning(const G4String& value)
throw G4HadronicException(__FILE__, __LINE__, text);
}
void G4Fragment::SetAngularMomentum(G4ThreeVector& v)
void G4Fragment::SetAngularMomentum(const G4ThreeVector& v)
{
spin = v.mag();
}
@@ -37,21 +37,24 @@
#include "G4PolynomialPDF.hh"
#include "Randomize.hh"
//#include <time.h>
using namespace std;
G4PolynomialPDF::G4PolynomialPDF(size_t n, const G4double* coeffs,
G4double x1, G4double x2) :
fX1(x1), fX2(x2), fChanged(true), fTolerance(1.e-8)
fX1(x1), fX2(x2), fChanged(true), fTolerance(1.e-8), fVerbose(0)
{
if(coeffs != NULL) SetCoefficients(n, coeffs);
if(coeffs != nullptr) SetCoefficients(n, coeffs);
else if(n > 0) SetNCoefficients(n);
}
G4PolynomialPDF::~G4PolynomialPDF()
{}
void G4PolynomialPDF::SetCoefficient(size_t i, G4double value)
{
while(i >= fCoefficients.size()) fCoefficients.push_back(0); /* Loop checking, 30-Oct-2015, G.Folger */
while(i >= fCoefficients.size()) fCoefficients.push_back(0);
/* Loop checking, 30-Oct-2015, G.Folger */
fCoefficients[i] = value;
fChanged = true;
}
@@ -69,8 +72,10 @@ void G4PolynomialPDF::SetCoefficients(size_t nCoeffs,
void G4PolynomialPDF::SetDomain(G4double x1, G4double x2)
{
if(x2 <= x1) {
G4cout << "G4PolynomialPDF::SetDomain(): Invalide domain! "
<< "(x1 = " << x1 << ", x2 = " << x2 << ")." << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::SetDomain() WARNING: Invalide domain! "
<< "(x1 = " << x1 << ", x2 = " << x2 << ")." << G4endl;
}
return;
}
fX1 = x1;
@@ -95,9 +100,11 @@ void G4PolynomialPDF::Normalize()
x2N*=fX2;
}
if(sum <= 0) {
G4cout << "G4PolynomialPDF::Normalize() PDF has non-positive area: "
<< sum << G4endl;
Dump();
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::Normalize() WARNING: PDF has non-positive area: "
<< sum << G4endl;
Dump();
}
return;
}
@@ -114,14 +121,16 @@ G4double G4PolynomialPDF::Evaluate(G4double x, G4int ddxPower)
/// ddxPower = 1: f = (d/dx) PDF
/// ddxPower = 2: f = (d2/dx2) PDF
if(ddxPower < -1 || ddxPower > 2) {
G4cout << "G4PolynomialPDF::GetX(): ddxPower " << ddxPower
<< " not implemented" << G4endl;
return 0;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: ddxPower " << ddxPower
<< " not implemented" << G4endl;
}
return 0.0;
}
double f = 0; // return value
double xN = 1; // x to the power N
double x1N = 1; // endpoint x1 to the power N; only used by CDF
double f = 0.; // return value
double xN = 1.; // x to the power N
double x1N = 1.; // endpoint x1 to the power N; only used by CDF
for(size_t i=0; i<=GetNCoefficients(); ++i) {
if(ddxPower == -1) { // CDF
if(i>0) f += GetCoefficient(i-1)*(xN - x1N)/i;
@@ -145,8 +154,10 @@ G4bool G4PolynomialPDF::HasNegativeMinimum(G4double x1, G4double x2)
// p': 2ax + b = 0 -> = 0 at min: x_extreme = -b/2a
if(x1 < fX1 || x2 > fX2 || x2 < x1) {
G4cout << "G4PolynomialPDF::HasNegativeMinimum(): Invalid range "
<< x1 << " - " << x2 << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::HasNegativeMinimum() WARNING: Invalid range "
<< x1 << " - " << x2 << G4endl;
}
return false;
}
@@ -183,8 +194,11 @@ G4double G4PolynomialPDF::GetRandomX()
if(fChanged) {
Normalize();
if(HasNegativeMinimum(fX1, fX2)) {
G4cout << "G4PolynomialPDF::GetRandomX(): PDF has negative values, returning 0..." << G4endl;
return 0;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetRandomX() WARNING: PDF has negative values, returning 0..."
<< G4endl;
}
return 0.0;
}
fChanged = false;
}
@@ -203,23 +217,31 @@ G4double G4PolynomialPDF::GetX(G4double p, G4double x1, G4double x2,
// input range checking
if(GetNCoefficients() == 0) {
G4cout << "G4PolynomialPDF::GetX(): no PDF defined!" << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: no PDF defined!" << G4endl;
}
return x2;
}
if(ddxPower < -1 || ddxPower > 1) {
G4cout << "G4PolynomialPDF::GetX(): ddxPower " << ddxPower
<< " not implemented" << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: ddxPower " << ddxPower
<< " not implemented" << G4endl;
}
return x2;
}
if(ddxPower == -1 && (p<0 || p>1)) {
G4cout << "G4PolynomialPDF::GetX(): p is out of range" << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: p is out of range" << G4endl;
}
return fX2;
}
// check limits
if(x2 <= x1 || x1 < fX1 || x2 > fX2) {
G4cout << "G4PolynomialPDF::GetX(): domain must have fX1 <= x1 < x2 <= fX2. "
<< "You sent x1 = " << x1 << ", x2 = " << x2 << "." << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: domain must have fX1 <= x1 < x2 <= fX2. "
<< "You sent x1 = " << x1 << ", x2 = " << x2 << "." << G4endl;
}
return x2;
}
@@ -298,8 +320,10 @@ G4double G4PolynomialPDF::GetX(G4double p, G4double x1, G4double x2,
}
if(f == 0) return guess;
if(dfdx == 0) {
G4cout << "G4PolynomialPDF::GetX(): got f != 0 but slope = 0 for ddxPower = "
<< ddxPower << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: got f != 0 but slope = 0 for ddxPower = "
<< ddxPower << G4endl;
}
return x2;
}
lastChange = - f/dfdx;
@@ -316,13 +340,18 @@ G4double G4PolynomialPDF::GetX(G4double p, G4double x1, G4double x2,
++iterations;
if(iterations > 50) {
if(p!=0) {
G4cout << "G4PolynomialPDF::GetX(): got stuck searching for " << p
<< " between " << x1 << " and " << x2 << " with ddxPower = "
<< ddxPower
<< ". Last guess was " << guess << "." << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: got stuck searching for " << p
<< " between " << x1 << " and " << x2 << " with ddxPower = "
<< ddxPower
<< ". Last guess was " << guess << "." << G4endl;
}
}
if(ddxPower==-1 && bisect) {
G4cout << "Bisceting and trying again..." << G4endl;
if(fVerbose > 0) {
G4cout << "G4PolynomialPDF::GetX() WARNING: Bisceting and trying again..."
<< G4endl;
}
return Bisect(p, x1, x2);
}
else return guess;