Import Geant4 10.3.1 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 100680 2016-10-31 10:52:13Z gcosmo $
|
||||
$Id: History 102724 2017-02-20 13:00:39Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
==========================================================
|
||||
@@ -14,6 +14,20 @@ code and to keep track of all tags.
|
||||
---------------------------------------------------------------
|
||||
* Please list in reverse chronological order (last date on top)
|
||||
---------------------------------------------------------------
|
||||
|
||||
16 February 2017 Vladimir Ivanchenko (hadr-mod-util-V10-02-10)
|
||||
- G4PolynomialPDF - added control on printout
|
||||
|
||||
14 February 2017 Vladimir Ivanchenko
|
||||
- G4Fragment - added method SetExcEnergyAndMomentum(...) allowing preserve
|
||||
excitation energy value without any precision lost, 4-momentum
|
||||
is recomputed; added class member and Get/Set method for floating
|
||||
levels number which was missing before
|
||||
|
||||
16 December 2016 Vladimir Ivanchenko (hadr-mod-util-V10-02-09)
|
||||
- G4Fragment - minor cleanup of check on excitation energy of
|
||||
a ground state
|
||||
|
||||
25 October 2016 V. Uzhinsky (hadr-mod-util-V10-02-08)
|
||||
- New method - void SetDefinition(G4ParticleDefinition * aDefinition);
|
||||
was added to G4Parton class. It is needed for an implementation of
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4Fragment.hh 96383 2016-04-11 09:06:57Z gcosmo $
|
||||
// $Id: G4Fragment.hh 102724 2017-02-20 13:00:39Z gcosmo $
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
inline void SetZandA_asInt(G4int Znew, G4int Anew);
|
||||
|
||||
inline G4double GetExcitationEnergy() const;
|
||||
inline void SetExcEnergyAndMomentum(G4double eexc, const G4LorentzVector&);
|
||||
|
||||
inline G4double GetGroundStateMass() const;
|
||||
|
||||
@@ -151,6 +152,9 @@ public:
|
||||
inline G4int GetNumberOfElectrons() const;
|
||||
inline void SetNumberOfElectrons(G4int value);
|
||||
|
||||
inline G4int GetFloatingLevelNumber() const;
|
||||
inline void SetFloatingLevelNumber(G4int value);
|
||||
|
||||
inline const G4ParticleDefinition * GetParticleDefinition() const;
|
||||
inline void SetParticleDefinition(const G4ParticleDefinition * p);
|
||||
|
||||
@@ -160,7 +164,7 @@ public:
|
||||
inline G4NuclearPolarization* GetNuclearPolarization() const;
|
||||
inline void SetNuclearPolarization(G4NuclearPolarization*);
|
||||
|
||||
void SetAngularMomentum(G4ThreeVector&);
|
||||
void SetAngularMomentum(const G4ThreeVector&);
|
||||
G4ThreeVector GetAngularMomentum() const;
|
||||
|
||||
// ============= PRIVATE METHODS ==============================
|
||||
@@ -201,11 +205,14 @@ private:
|
||||
|
||||
// Gamma evaporation data members
|
||||
G4int numberOfShellElectrons;
|
||||
G4int xLevel;
|
||||
|
||||
const G4ParticleDefinition* theParticleDefinition;
|
||||
|
||||
G4double spin;
|
||||
G4double theCreationTime;
|
||||
|
||||
static const G4double minFragExcitation;
|
||||
};
|
||||
|
||||
// ============= INLINE METHOD IMPLEMENTATIONS ===================
|
||||
@@ -239,7 +246,10 @@ inline void G4Fragment::operator delete(void * aFragment)
|
||||
inline void G4Fragment::CalculateExcitationEnergy()
|
||||
{
|
||||
theExcitationEnergy = theMomentum.mag() - theGroundStateMass;
|
||||
if(theExcitationEnergy < 0.0) { ExcitationEnergyWarning(); }
|
||||
if(theExcitationEnergy < minFragExcitation) {
|
||||
if(theExcitationEnergy < -minFragExcitation) { ExcitationEnergyWarning(); }
|
||||
theExcitationEnergy = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
inline G4double
|
||||
@@ -280,6 +290,14 @@ inline G4double G4Fragment::GetGroundStateMass() const
|
||||
return theGroundStateMass;
|
||||
}
|
||||
|
||||
inline void G4Fragment::SetExcEnergyAndMomentum(G4double eexc,
|
||||
const G4LorentzVector& v)
|
||||
{
|
||||
theExcitationEnergy = eexc;
|
||||
theMomentum.set(0.0, 0.0, 0.0, theGroundStateMass + eexc);
|
||||
theMomentum.boost(v.boostVector());
|
||||
}
|
||||
|
||||
inline G4double G4Fragment::GetBindingEnergy() const
|
||||
{
|
||||
return (theA-theZ)*CLHEP::neutron_mass_c2 + theZ*CLHEP::proton_mass_c2
|
||||
@@ -406,6 +424,16 @@ inline void G4Fragment::SetSpin(G4double value)
|
||||
spin = value;
|
||||
}
|
||||
|
||||
inline G4int G4Fragment::GetFloatingLevelNumber() const
|
||||
{
|
||||
return xLevel;
|
||||
}
|
||||
|
||||
inline void G4Fragment::SetFloatingLevelNumber(G4int value)
|
||||
{
|
||||
xLevel = value;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4ParticleDefinition* G4Fragment::GetParticleDefinition(void) const
|
||||
{
|
||||
|
||||
@@ -51,8 +51,8 @@ class G4PolynomialPDF
|
||||
public:
|
||||
G4PolynomialPDF(size_t n = 0, const double* coeffs = nullptr,
|
||||
G4double x1=0, G4double x2=1);
|
||||
~G4PolynomialPDF() {};
|
||||
|
||||
~G4PolynomialPDF();
|
||||
// Setters and Getters for coefficients
|
||||
inline void SetNCoefficients(size_t n) { fCoefficients.resize(n); fChanged = true; }
|
||||
inline size_t GetNCoefficients() const { return fCoefficients.size(); }
|
||||
@@ -94,7 +94,8 @@ class G4PolynomialPDF
|
||||
// Beware that if x1 and x2 are not set carefully there may be multiple
|
||||
// solutions, and care is not taken to select a particular one among them.
|
||||
// Returns x2 on error
|
||||
G4double GetX( G4double p, G4double x1, G4double x2, G4int ddxPower = 0, G4double guess = 1.e99, G4bool bisect = true );
|
||||
G4double GetX( G4double p, G4double x1, G4double x2, G4int ddxPower = 0,
|
||||
G4double guess = 1.e99, G4bool bisect = true );
|
||||
inline G4double EvalInverseCDF(G4double p) { return GetX(p, fX1, fX2, -1, fX1 + p*(fX2-fX1)); }
|
||||
G4double Bisect( G4double p, G4double x1, G4double x2 );
|
||||
|
||||
@@ -107,8 +108,9 @@ class G4PolynomialPDF
|
||||
G4double fX1;
|
||||
G4double fX2;
|
||||
std::vector<G4double> fCoefficients;
|
||||
G4bool fChanged;
|
||||
G4bool fChanged;
|
||||
G4double fTolerance;
|
||||
G4int fVerbose;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user