Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+19
View File
@@ -7,6 +7,25 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-10-29 Vladimir Ivanchenko (hadr-util-V11-02-05)
- G4LegendrePolynomial - optimized implementation by Isaac Kunen GitHub PR #70
## 2024-09-09 Vladimir Ivanchenko (hadr-util-V11-02-04)
- G4IsotopeList - added table with low-energy threshold energies per atomic number.
- G4NucleaRadii - added two static function to describe threshold shape by the
old parameterisations derived from GHEISHA.
## 2024-08-21 Gabriele Cosmo (hadr-util-V11-02-03)
- Fixed reported Coverity defects for use of std::move() and const G4String&;
in G4HadronicDeveloperParameters use const G4String& and const_iterator.
## 2024-08-02 Alberto Ribon (hadr-util-V11-02-02)
- G4HadronicParameters : introduced Getter/Setter for selecting the PT table
type (a choice between "calendf" and "njoy" ) for the URR treatment of
low-energy neutrons.
( Note that this choice must be done at initialization time, therefore it
cannot be made via UI command in ParticleHP. )
## 2024-06-06 Vladimir Ivanchenko (hadr-util-V11-02-01)
- G4HadronicParameters: introduced Getter/Setter of flag of the NUDEX gamma
de-excitation module.
@@ -45,50 +45,50 @@ class G4HadronicDeveloperParameters
G4HadronicDeveloperParameters &operator=( const G4HadronicDeveloperParameters& );
public:
G4bool Set( const std::string name , const G4bool );
G4bool Set( const std::string name , const G4int );
G4bool Set( const std::string name , const G4double );
G4bool GetDefault( const std::string name , G4bool& value );
G4bool GetDefault( const std::string name , G4int& value );
G4bool GetDefault( const std::string name , G4double& value );
G4bool Get( const std::string name , G4bool& value );
G4bool Get( const std::string name , G4int& value );
G4bool Get( const std::string name , G4double& value );
G4bool DeveloperGet( const std::string name , G4bool& value );
G4bool DeveloperGet( const std::string name , G4int& value );
G4bool DeveloperGet( const std::string name , G4double& value );
void Dump( const std::string name );
G4bool Set( const G4String& name , const G4bool );
G4bool Set( const G4String& name , const G4int );
G4bool Set( const G4String& name , const G4double );
G4bool GetDefault( const G4String& name , G4bool& value );
G4bool GetDefault( const G4String& name , G4int& value );
G4bool GetDefault( const G4String& name , G4double& value );
G4bool Get( const G4String& name , G4bool& value );
G4bool Get( const G4String& name , G4int& value );
G4bool Get( const G4String& name , G4double& value );
G4bool DeveloperGet( const G4String& name , G4bool& value );
G4bool DeveloperGet( const G4String& name , G4int& value );
G4bool DeveloperGet( const G4String& name , G4double& value );
void Dump( const G4String& name );
//protected:
public:
G4bool SetDefault( const std::string name , const G4bool value );
G4bool SetDefault( const std::string name , const G4int value , G4int lower_limit = -INT_MAX , G4int upper_limit = INT_MAX );
G4bool SetDefault( const std::string name , const G4double value , G4double lower_limit = -DBL_MAX , G4double upper_limit = DBL_MAX );
G4bool SetDefault( const G4String& name , const G4bool value );
G4bool SetDefault( const G4String& name , const G4int value , G4int lower_limit = -INT_MAX , G4int upper_limit = INT_MAX );
G4bool SetDefault( const G4String& name , const G4double value , G4double lower_limit = -DBL_MAX , G4double upper_limit = DBL_MAX );
private:
G4bool get( const std::string name , G4bool& value , G4bool check_change = false );
G4bool get( const std::string name , G4int& value , G4bool check_change = false );
G4bool get( const std::string name , G4double& value , G4bool check_change= false );
G4bool get( const G4String& name , G4bool& value , G4bool check_change = false );
G4bool get( const G4String& name , G4int& value , G4bool check_change = false );
G4bool get( const G4String& name , G4double& value , G4bool check_change= false );
std::map<std::string,G4bool> b_values;
std::map<std::string,const G4bool> b_defaults;
std::map<G4String,G4bool> b_values;
std::map<G4String,const G4bool> b_defaults;
std::map<std::string,G4int> i_values;
std::map<std::string,const G4int> i_defaults;
std::map<std::string,std::pair<const G4int,const G4int>> i_limits;
std::map<G4String,G4int> i_values;
std::map<G4String,const G4int> i_defaults;
std::map<G4String,std::pair<const G4int,const G4int>> i_limits;
std::map<std::string,G4double> values;
std::map<std::string,const G4double> defaults;
std::map<std::string,std::pair<const G4double,const G4double>> limits;
std::map<G4String,G4double> values;
std::map<G4String,const G4double> defaults;
std::map<G4String,std::pair<const G4double,const G4double>> limits;
G4bool check_value_within_limits( std::pair<const G4double,const G4double>& , G4double );
G4bool check_value_within_limits( std::pair<const G4int,const G4int>& , G4int );
void issue_no_param( const std::string& name );
void issue_has_changed( const std::string& name );
void issue_non_eligible_value( const std::string& name );
void issue_is_already_defined( const std::string& name );
void issue_is_modified( const std::string& name );
void issue_no_param( const G4String& name );
void issue_has_changed( const G4String& name );
void issue_non_eligible_value( const G4String& name );
void issue_is_already_defined( const G4String& name );
void issue_is_modified( const G4String& name );
};
#endif
@@ -31,7 +31,7 @@
class G4HadronicException : public std::exception {
public:
G4HadronicException(G4String in, G4int at, G4String mess);
G4HadronicException(const G4String& in, G4int at, const G4String& mess);
virtual ~G4HadronicException() throw();
@@ -155,6 +155,13 @@ class G4HadronicParameters {
void SetEnableNUDEX( G4bool val );
// NUDEX gamma de-excitation is enabled/disabled.
inline const G4String& GetTypeTablePT() const;
void SetTypeTablePT( const G4String& typeTablePT );
// Specify the type of PT table - between "calendf" and "njoy" for
// the URR (Unresolved Resonance Region) treatment of low-energy neutrons.
// ( Note that there is no default: an empty string "" is returned if
// it is not set explicitly. )
inline G4double GetEPRelativeLevel() const;
inline G4double GetEPAbsoluteLevel() const;
inline G4int GetEPReportLevel() const;
@@ -220,6 +227,7 @@ class G4HadronicParameters {
G4bool fChargeExchange = false;
G4bool fBinaryDebug = false;
G4String fTypeTablePT = "";
G4String fDirPARTICLEXS = "";
G4String fPhysListDocDir = "";
G4String fPhysListName = "";
@@ -324,6 +332,10 @@ inline G4bool G4HadronicParameters::EnableNUDEX() const {
return fEnableNUDEX;
}
inline const G4String& G4HadronicParameters::GetTypeTablePT() const {
return fTypeTablePT;
}
inline G4bool G4HadronicParameters::EnableCoherentChargeExchange() const {
return fChargeExchange;
}
@@ -39,6 +39,8 @@
// All arrays have length ZMAX = 101
// access to this data via atomic number Z (1 - 100)
static const G4int ZMAXNUCLEARDATA = 100;
static const G4int amin[] = {
0,
1, 3, 6, 9, 10, 12, 14, 16, 19, 20, //1-10
@@ -78,6 +80,19 @@ static const G4double aeff[] = {
204.383, 207.217, 208.98, 208.982, 209.987, 222.018, 223.02, 226.025, 227.028, 232.038, //81-90
231.036, 238.029, 237.048, 244.064, 243.061, 247.07, 247.07, 251.08, 252.083, 257.095}; //91-100
static const G4double lowEnergyLimitMeV[] = {
0,
0, 0, 0, 0, 0, 6., 0, 4., 0, 0, //1-10
0, 0, 0, 1.6, 1.4, 1.4, 1.3, 1.6, 1.2, 1.3, //11-20
0.2, 0.2, 0.4, 0, 0, 1.0, 1.3, 0.1, 0.8, 0.2, //21-30
0.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, //31-40
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //41-50
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //51-60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //61-70
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //71-80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //81-90
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //91-100
static const G4String elementName[] = {
"",
"Hydrogen", "Helium", "Lithium", "Berylium", "Boron", "Carbon",
@@ -34,7 +34,7 @@
//
// Creation date: February 2015
//
// Modifications:
// Modifications: 29 October 2024 Isaac Kunen
//
// Legendre Polynomial
//
@@ -51,16 +51,24 @@ class G4LegendrePolynomial
{
public:
// Access to coefficients
static size_t GetNCoefficients(size_t order) { return order+1; }
G4double GetCoefficient(size_t i, size_t order);
static std::size_t GetNCoefficients(std::size_t order) { return order+1; }
G4double GetCoefficient(std::size_t i, std::size_t order);
// Evaluation functions
G4double EvalLegendrePoly(G4int order, G4double x);
G4double EvalAssocLegendrePoly(G4int l, G4int m, G4double x);
// cache is not used; use EvalAssocLegendrePoly(l, m, x) instead.
G4double EvalAssocLegendrePoly(G4int l, G4int m, G4double x,
std::map<G4int, std::map<G4int, G4double> >* cache = NULL);
std::map<G4int, std::map<G4int, G4double> >* cache)
{
(void) cache; // suppress compiler warning for unused cache
return EvalAssocLegendrePoly(l, m, x);
}
protected: // Cache coefficients for speed
void BuildUpToOrder(size_t order);
void BuildUpToOrder(std::size_t order);
std::vector< std::vector<G4double> > fCoefficients;
};
@@ -87,6 +87,10 @@ public:
const G4ParticleDefinition* theParticle,
G4double ekin);
// parameterisation of threshold shape of cross section
static G4double NeutronInelasticShape(G4int Z, G4double ekin);
static G4double ProtonInelasticShape(G4int Z, G4double ekin);
static G4Pow* fG4pow;
static const G4double r0[93];
@@ -33,27 +33,28 @@
class G4ping
{
public:
G4ping(G4String aName) : theName(aName) {};
public:
G4ping(const G4String& aName) : theName(aName) {}
void push_back(G4String aS) {theS.push_back(aS);}
void push_back(const G4String& aS) {theS.push_back(aS);}
void push_back(G4double aD) {theD.push_back(aD);}
void push_back(G4LorentzVector aV) {theV.push_back(aV);}
void push_back(const G4LorentzVector& aV) {theV.push_back(aV);}
void dump()
{
if(std::getenv(theName))
{
size_t i(0);
for(i=0; i<theS.size(); i++)
std::size_t i(0);
for(i=0; i<theS.size(); ++i)
{
G4cout << theS[i]<<", ";
}
for(i=0; i<theD.size(); i++)
for(i=0; i<theD.size(); ++i)
{
G4cout << theD[i]<<", ";
}
for(i=0; i<theV.size(); i++)
for(i=0; i<theV.size(); ++i)
{
G4cout << theV[i]<<", ";
}
@@ -63,7 +64,9 @@
theD.clear();
theV.clear();
}
private:
private:
std::vector<G4String> theS;
std::vector<G4double> theD;
std::vector<G4LorentzVector> theV;
@@ -578,7 +578,7 @@ G4bool G4Fancy3DNucleus::ReduceSum()
}
if ( best < 0 )
{
G4String text = "G4Fancy3DNucleus.cc: Logic error in ReduceSum()";
const G4String& text = "G4Fancy3DNucleus.cc: Logic error in ReduceSum()";
throw G4HadronicException(__FILE__, __LINE__, text);
}
momentum[testSums[best].Index]-=testSums[best].Vector;
@@ -36,13 +36,13 @@ G4HadronicDeveloperParameters::G4HadronicDeveloperParameters(){
G4HadronicDeveloperParameters::G4HadronicDeveloperParameters( const G4HadronicDeveloperParameters& ){
}
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const G4bool value ){
G4bool G4HadronicDeveloperParameters::SetDefault( const G4String& name , const G4bool value ){
G4bool status = false;
const std::map< std::string , const G4bool >::iterator it = b_defaults.find( name );
if ( it == b_defaults.end() ) {
const std::map< G4String , const G4bool >::const_iterator it = b_defaults.find( name );
if ( it == b_defaults.cend() ) {
status = true;
b_defaults.insert( std::pair<std::string, const G4bool>( name , value ) );
b_values.insert( std::pair<std::string, G4bool>( name , value ) );
b_defaults.insert( std::pair<G4String, const G4bool>( name , value ) );
b_values.insert( std::pair<G4String, G4bool>( name , value ) );
} else {
/*error*/
issue_is_already_defined( name );
@@ -50,14 +50,14 @@ G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const
return status;
}
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const G4int value , G4int lower_limit , G4int upper_limit ){
G4bool G4HadronicDeveloperParameters::SetDefault( const G4String& name , const G4int value , G4int lower_limit , G4int upper_limit ){
G4bool status = false;
const std::map< std::string , const G4int >::iterator it = i_defaults.find( name );
if ( it == i_defaults.end() ) {
const std::map< G4String , const G4int >::const_iterator it = i_defaults.find( name );
if ( it == i_defaults.cend() ) {
status = true;
i_defaults.insert( std::pair<std::string, const G4int>( name , value ) );
i_values.insert( std::pair<std::string, G4int>( name , value ) );
i_limits.insert( std::pair< std::string,std::pair< const G4int , const G4int> >( name, std::pair< const G4int , const G4int> ( lower_limit , upper_limit ) ) );
i_defaults.insert( std::pair<G4String, const G4int>( name , value ) );
i_values.insert( std::pair<G4String, G4int>( name , value ) );
i_limits.insert( std::pair< G4String,std::pair< const G4int , const G4int> >( name, std::pair< const G4int , const G4int> ( lower_limit , upper_limit ) ) );
} else {
/*error*/
issue_is_already_defined( name );
@@ -65,14 +65,14 @@ G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const
return status;
}
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const G4double value , G4double lower_limit , G4double upper_limit ){
G4bool G4HadronicDeveloperParameters::SetDefault( const G4String& name , const G4double value , G4double lower_limit , G4double upper_limit ){
G4bool status = false;
const std::map< std::string , const G4double >::iterator it = defaults.find( name );
if ( it == defaults.end() ) {
const std::map< G4String , const G4double >::const_iterator it = defaults.find( name );
if ( it == defaults.cend() ) {
status = true;
defaults.insert( std::pair<std::string, const G4double>( name , value ) );
values.insert( std::pair<std::string, G4double>( name , value ) );
limits.insert( std::pair< std::string,std::pair< const G4double , const G4double> >( name, std::pair< const G4double , const G4double> ( lower_limit , upper_limit ) ) );
defaults.insert( std::pair<G4String, const G4double>( name , value ) );
values.insert( std::pair<G4String, G4double>( name , value ) );
limits.insert( std::pair< G4String,std::pair< const G4double , const G4double> >( name, std::pair< const G4double , const G4double> ( lower_limit , upper_limit ) ) );
} else {
/*error*/
issue_is_already_defined( name );
@@ -80,10 +80,10 @@ G4bool G4HadronicDeveloperParameters::SetDefault( const std::string name , const
return status;
}
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4bool value ){
G4bool G4HadronicDeveloperParameters::Set( const G4String& name , const G4bool value ){
G4bool status = false;
const std::map<std::string,G4bool>::iterator it = b_values.find( name );
if ( it != b_values.end() ) {
const std::map<G4String,G4bool>::iterator it = b_values.find( name );
if ( it != b_values.cend() ) {
if ( it->second == b_defaults.find(name)->second ) {
status = true;
it->second = value;
@@ -98,10 +98,10 @@ G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4bool
return status;
}
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4int value ){
G4bool G4HadronicDeveloperParameters::Set( const G4String& name , const G4int value ){
G4bool status = false;
const std::map<std::string,G4int>::iterator it = i_values.find( name );
if ( it != i_values.end() ) {
const std::map<G4String,G4int>::iterator it = i_values.find( name );
if ( it != i_values.cend() ) {
if ( it->second == i_defaults.find(name)->second ) {
if ( check_value_within_limits( i_limits.find(name)->second , value ) ) {
/*value is OK*/
@@ -122,10 +122,10 @@ G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4int
return status;
}
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4double value ){
G4bool G4HadronicDeveloperParameters::Set( const G4String& name , const G4double value ){
G4bool status = false;
const std::map<std::string,G4double>::iterator it = values.find( name );
if ( it != values.end() ) {
const std::map<G4String,G4double>::iterator it = values.find( name );
if ( it != values.cend() ) {
if ( it->second == defaults.find(name)->second ) {
if ( check_value_within_limits( limits.find(name)->second , value ) ) {
/*value is OK*/
@@ -146,10 +146,10 @@ G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4doub
return status;
}
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4bool& value ) {
G4bool G4HadronicDeveloperParameters::GetDefault( const G4String& name , G4bool& value ) {
G4bool status = false;
const std::map<std::string,const G4bool>::iterator it = b_defaults.find( name );
if ( it != b_defaults.end() ) {
const std::map<G4String,const G4bool>::const_iterator it = b_defaults.find( name );
if ( it != b_defaults.cend() ) {
status = true;
value = it->second;
} else {
@@ -159,10 +159,10 @@ G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4boo
return status;
}
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4int& value ) {
G4bool G4HadronicDeveloperParameters::GetDefault( const G4String& name , G4int& value ) {
G4bool status = false;
const std::map<std::string,const G4int>::iterator it = i_defaults.find( name );
if ( it != i_defaults.end() ) {
const std::map<G4String,const G4int>::const_iterator it = i_defaults.find( name );
if ( it != i_defaults.cend() ) {
status = true;
value = it->second;
} else {
@@ -172,10 +172,10 @@ G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4int
return status;
}
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4double& value ) {
G4bool G4HadronicDeveloperParameters::GetDefault( const G4String& name , G4double& value ) {
G4bool status = false;
const std::map<std::string,const G4double>::iterator it = defaults.find( name );
if ( it != defaults.end() ) {
const std::map<G4String,const G4double>::const_iterator it = defaults.find( name );
if ( it != defaults.cend() ) {
status = true;
value = it->second;
} else {
@@ -185,18 +185,18 @@ G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4dou
return status;
}
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4double& value ) {
G4bool G4HadronicDeveloperParameters::Get( const G4String& name , G4double& value ) {
return get( name , value );
}
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4double& value ) {
G4bool G4HadronicDeveloperParameters::DeveloperGet( const G4String& name , G4double& value ) {
return get( name , value , true );
}
G4bool G4HadronicDeveloperParameters::get( const std::string name , G4bool& value , G4bool check_change ) {
G4bool G4HadronicDeveloperParameters::get( const G4String& name , G4bool& value , G4bool check_change ) {
G4bool status = false;
const std::map<std::string,G4bool>::iterator it = b_values.find( name );
if ( it != b_values.end() ) {
const std::map<G4String,G4bool>::const_iterator it = b_values.find( name );
if ( it != b_values.cend() ) {
status = true;
value = it->second;
if ( check_change && value != b_defaults.find(name)->second ) {
@@ -210,18 +210,18 @@ G4bool G4HadronicDeveloperParameters::get( const std::string name , G4bool& valu
return status;
}
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4int& value ) {
G4bool G4HadronicDeveloperParameters::Get( const G4String& name , G4int& value ) {
return get( name , value );
}
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4int& value ) {
G4bool G4HadronicDeveloperParameters::DeveloperGet( const G4String& name , G4int& value ) {
return get( name , value , true );
}
G4bool G4HadronicDeveloperParameters::get( const std::string name , G4int& value , G4bool check_change ) {
G4bool G4HadronicDeveloperParameters::get( const G4String& name , G4int& value , G4bool check_change ) {
G4bool status = false;
const std::map<std::string,G4int>::iterator it = i_values.find( name );
if ( it != i_values.end() ) {
const std::map<G4String,G4int>::const_iterator it = i_values.find( name );
if ( it != i_values.cend() ) {
status = true;
value = it->second;
if ( check_change && value != i_defaults.find(name)->second ) {
@@ -235,18 +235,18 @@ G4bool G4HadronicDeveloperParameters::get( const std::string name , G4int& value
return status;
}
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4bool& value ) {
G4bool G4HadronicDeveloperParameters::Get( const G4String& name , G4bool& value ) {
return get( name , value );
}
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4bool& value ) {
G4bool G4HadronicDeveloperParameters::DeveloperGet( const G4String& name , G4bool& value ) {
return get( name , value , true );
}
G4bool G4HadronicDeveloperParameters::get( const std::string name , G4double& value , G4bool check_change ) {
G4bool G4HadronicDeveloperParameters::get( const G4String& name , G4double& value , G4bool check_change ) {
G4bool status = false;
const std::map<std::string,G4double>::iterator it = values.find( name );
if ( it != values.end() ) {
const std::map<G4String,G4double>::const_iterator it = values.find( name );
if ( it != values.cend() ) {
status = true;
value = it->second;
if ( check_change && value != defaults.find(name)->second ) {
@@ -260,15 +260,15 @@ G4bool G4HadronicDeveloperParameters::get( const std::string name , G4double& va
return status;
}
void G4HadronicDeveloperParameters::Dump( const std::string name ) {
//const std::map<std::string,G4double>::iterator it = values.find( name );
if ( b_values.find( name ) != b_values.end() ) {
void G4HadronicDeveloperParameters::Dump( const G4String& name ) {
//const std::map<G4String,G4double>::const_iterator it = values.find( name );
if ( b_values.find( name ) != b_values.cend() ) {
G4cout << "G4HadronicDeveloperParameters: "
<< "name = " << name
<< ", default value = " << b_defaults.find( name )->second
<< ", current value = " << b_values.find( name )->second
<< "." << G4endl;
} else if ( i_values.find( name ) != i_values.end() ) {
} else if ( i_values.find( name ) != i_values.cend() ) {
G4cout << "G4HadronicDeveloperParameters: "
<< "name = " << name
<< ", default value = " << i_defaults.find( name )->second
@@ -276,7 +276,7 @@ void G4HadronicDeveloperParameters::Dump( const std::string name ) {
<< ", upper limit = " << i_limits.find( name )->second.second
<< ", current value = " << i_values.find( name )->second
<< "." << G4endl;
} else if ( values.find( name ) != values.end() ) {
} else if ( values.find( name ) != values.cend() ) {
G4cout << "G4HadronicDeveloperParameters: "
<< "name = " << name
<< ", default value = " << defaults.find( name )->second
@@ -306,34 +306,34 @@ G4bool G4HadronicDeveloperParameters::check_value_within_limits( std::pair<const
}
}
void G4HadronicDeveloperParameters::issue_no_param( const std::string& name ){
std::string text("Parameter ");
void G4HadronicDeveloperParameters::issue_no_param( const G4String& name ){
G4String text("Parameter ");
text += name;
text += " does not exist.";
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_001", FatalException , text.c_str() );
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_001", FatalException , text );
}
void G4HadronicDeveloperParameters::issue_has_changed( const std::string& name ) {
std::string text("Parameter ");
void G4HadronicDeveloperParameters::issue_has_changed( const G4String& name ) {
G4String text("Parameter ");
text += name;
text += " has already been changed once.";
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_002", FatalException , text.c_str() );
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_002", FatalException , text );
}
void G4HadronicDeveloperParameters::issue_non_eligible_value( const std::string& name ) {
std::string text("The value of the parameter ");
void G4HadronicDeveloperParameters::issue_non_eligible_value( const G4String& name ) {
G4String text("The value of the parameter ");
text += name;
text += " is outside the allowable range.";
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_003", FatalException , text.c_str() );
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_003", FatalException , text );
}
void G4HadronicDeveloperParameters::issue_is_already_defined( const std::string& name ) {
std::string text("Parameter ");
void G4HadronicDeveloperParameters::issue_is_already_defined( const G4String& name ) {
G4String text("Parameter ");
text += name;
text += " is already defined.";
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_004", FatalException , text.c_str() );
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_004", FatalException , text );
}
void G4HadronicDeveloperParameters::issue_is_modified( const std::string& name ) {
std::string text("Parameter ");
void G4HadronicDeveloperParameters::issue_is_modified( const G4String& name ) {
G4String text("Parameter ");
text += name;
text += " has changed from default value.";
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_005", JustWarning , text.c_str() );
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_005", JustWarning , text );
}
@@ -27,7 +27,7 @@
#include <iostream>
G4HadronicException::G4HadronicException(G4String in, G4int at, G4String mess)
G4HadronicException::G4HadronicException(const G4String& in, G4int at, const G4String& mess)
: theMessage{mess}, theName{in}, theLine{at} {
std::ostringstream os;
@@ -283,6 +283,11 @@ void G4HadronicParameters::SetEnableNUDEX( G4bool val ) {
}
void G4HadronicParameters::SetTypeTablePT( const G4String& typeTablePT ) {
if ( ! IsLocked() ) fTypeTablePT = typeTablePT;
}
void G4HadronicParameters::SetEnableCoherentChargeExchange( G4bool val ) {
if ( ! IsLocked() ) fChargeExchange = val;
}
@@ -175,7 +175,7 @@ G4KineticTrack::G4KineticTrack(const G4ParticleDefinition* aDefinition,
//
G4DecayTable* theDecayTable = theDefinition->GetDecayTable();
if (theDecayTable != 0)
if (theDecayTable != nullptr)
{
nChannels = theDecayTable->entries();
@@ -199,7 +199,7 @@ G4KineticTrack::G4KineticTrack(const G4ParticleDefinition* aDefinition,
theDaughterMass = 0;
theDaughterWidth = 0;
theActualWidth = 0;
G4bool * theDaughterIsShortLived = 0;
G4bool * theDaughterIsShortLived = nullptr;
if(nChannels!=0) theActualWidth = new G4double[nChannels];
@@ -388,11 +388,11 @@ G4KineticTrack::G4KineticTrack(const G4ParticleDefinition* aDefinition,
theActualWidth[index] = thePoleWidth * theMassRatio *
theMomRatio;
delete [] theDaughterMass;
theDaughterMass = 0;
theDaughterMass = nullptr;
delete [] theDaughterWidth;
theDaughterWidth = 0;
theDaughterWidth = nullptr;
delete [] theDaughterIsShortLived;
theDaughterIsShortLived = 0;
theDaughterIsShortLived = nullptr;
}
else // nDaughter = 1 ( e.g. K0 decays 50% to Kshort, 50% Klong
@@ -466,7 +466,7 @@ G4KineticTrack& G4KineticTrack::operator=(const G4KineticTrack& right)
theTotal4Momentum = right.theTotal4Momentum;
theNucleon = right.theNucleon;
theStateToNucleus = right.theStateToNucleus;
if (theActualWidth != 0) delete [] theActualWidth;
delete [] theActualWidth;
nChannels = right.GetnChannels();
theActualWidth = new G4double[nChannels];
for (G4int i = 0; i < nChannels; ++i) theActualWidth[i] = right.theActualWidth[i];
@@ -509,7 +509,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
{
G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
G4cerr << " track has no particle definition associated."<<G4endl;
return 0;
return nullptr;
}
G4DecayTable* theDecayTable = thisDefinition->GetDecayTable();
if(!theDecayTable)
@@ -517,7 +517,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
G4cerr << " particle definition has no decay table associated."<<G4endl;
G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
return 0;
return nullptr;
}
G4int chargeBalance = G4lrint(theDefinition->GetPDGCharge() );
@@ -557,7 +557,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
// cout << "DECAY Total Width " << theSumActualWidth << G4endl;
// cout << "DECAY Total Width " << theTotalActualWidth << G4endl;
G4double r = theTotalActualWidth * G4UniformRand();
G4VDecayChannel* theDecayChannel(0);
G4VDecayChannel* theDecayChannel(nullptr);
chosench=-1;
for (G4int index = nChannels - 1; index >= 0; --index)
{
@@ -572,13 +572,13 @@ G4KineticTrackVector* G4KineticTrack::Decay()
delete [] theCumActualWidth;
if(!theDecayChannel)
if(theDecayChannel == nullptr)
{
G4cerr << "Error condition encountered in G4KineticTrack::Decay()"<<G4endl;
G4cerr << " decay channel has 0x0 channel associated."<<G4endl;
G4cerr << " particle was "<<thisDefinition->GetParticleName()<<G4endl;
G4cerr << " channel index "<< chosench << "of "<<nChannels<<"channels"<<G4endl;
return 0;
return nullptr;
}
theParentName = theDecayChannel->GetParentName();
theParentMass = this->GetActualMass();
@@ -694,7 +694,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
theDaughtersName4,
masses);
G4DecayProducts* theDecayProducts = thePhaseSpaceDecayChannel.DecayIt();
if(!theDecayProducts)
if(theDecayProducts == nullptr)
{
G4ExceptionDescription ed;
ed << "Error condition encountered: phase-space decay failed." << G4endl
@@ -704,7 +704,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
<< theDaughtersName1 << " " << theDaughtersName2 << " " << theDaughtersName3 << " "
<< theDaughtersName4 << G4endl;
G4Exception( "G4KineticTrack::Decay ", "HAD_KINTRACK_001", JustWarning, ed );
return 0;
return nullptr;
}
//
@@ -720,7 +720,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
G4LorentzVector momentumBalanceCMS(0);
G4KineticTrackVector* theDecayProductList = new G4KineticTrackVector;
G4int dEntries = theDecayProducts->entries();
const G4ParticleDefinition * aProduct = 0;
const G4ParticleDefinition * aProduct = nullptr;
// Use the integer round mass in keV to get an unique ID for the parent resonance
G4int uniqueID = static_cast< G4int >( round( Get4Momentum().mag() / CLHEP::keV ) );
for (G4int i=dEntries; i > 0; --i)
@@ -757,7 +757,7 @@ G4KineticTrackVector* G4KineticTrack::Decay()
}
else
{
return 0;
return nullptr;
}
}
@@ -862,11 +862,3 @@ G4double G4KineticTrack::IntegrateCMMomentum2() const
theLowerLimit, theUpperLimit, nIterations);
return theIntegralOverMass2;
}
@@ -31,7 +31,7 @@
using namespace std;
G4double G4LegendrePolynomial::GetCoefficient(size_t i, size_t order)
G4double G4LegendrePolynomial::GetCoefficient(std::size_t i, std::size_t order)
{
if(order >= fCoefficients.size()) BuildUpToOrder(order);
if(order >= fCoefficients.size() ||
@@ -46,81 +46,98 @@ G4double G4LegendrePolynomial::EvalLegendrePoly(G4int order, G4double x)
return (EvalAssocLegendrePoly(order,0,x));
}
G4double G4LegendrePolynomial::EvalAssocLegendrePoly(G4int l, G4int m, G4double x,
map<G4int, map<G4int, G4double> >* cache)
G4double G4LegendrePolynomial::EvalAssocLegendrePoly(G4int l, G4int m, G4double x)
{
// Calculate P_l^m(x).
// If cache ptr is non-null, use cache[l][m] if it exists, otherwise compute
// P_l^m(x) and cache it in that position. The cache speeds up calculations
// where many P_l^m computations are need at the same value of x.
// Invalid calls --> 0. (Keeping for backward compatibility; should we throw instead?)
if (l<0 || m<-l || m>l) return 0.0;
if(l<0 || m<-l || m>l) return 0;
G4Pow* g4pow = G4Pow::GetInstance();
// New check: g4pow doesn't handle integer arguments over 512.
// For us that means:
if ((l+m) > 512 || (l-m) > 512 || (2*m) > 512) return 0.0;
// Use non-log factorial for low l, m: it is more efficient until
// l and m get above 10 or so.
// FIXME: G4Pow doesn't check whether the argument gets too large,
// which is unsafe! Max is 512; VI: It is assume that Geant4 does not
// need higher order
if(m<0) {
G4double value = (m%2 ? -1. : 1.) * EvalAssocLegendrePoly(l, -m, x);
if(l < 10) return value * g4pow->factorial(l+m)/g4pow->factorial(l-m);
else { return value * G4Exp(g4pow->logfactorial(l+m) - g4pow->logfactorial(l-m));
}
}
G4Pow* g4pow = G4Pow::GetInstance();
G4double x2 = x*x;
// hard-code the first few orders for speed
if(l==0) return 1;
if(l==1) {
if(m==0){return x;}
/*m==1*/ return -sqrt(1.-x*x);
}
if(l<5) {
G4double x2 = x*x;
if(l==2) {
if(m==0){return 0.5*(3.*x2 - 1.);}
if(m==1){return -3.*x*sqrt(1.-x2);}
/*m==2*/ return 3.*(1.-x2);
}
if(l==3) {
if(m==0){return 0.5*(5.*x*x2 - 3.*x);}
if(m==1){return -1.5*(5.*x2-1.)*sqrt(1.-x2);}
if(m==2){return 15.*x*(1.-x2);}
/*m==3*/ return -15.*(1.-x2)*sqrt(1.-x2);
}
if(l==4) {
if(m==0){return 0.125*(35.*x2*x2 - 30.*x2 + 3.);}
if(m==1){return -2.5*(7.*x*x2-3.*x)*sqrt(1.-x2);}
if(m==2){return 7.5*(7.*x2-1.)*(1.-x2);}
if(m==3){return -105.*x*(1.-x2)*sqrt(1.-x2);}
/*m==4*/ return 105.*(1. - 2.*x2 + x2*x2);
}
}
switch (l) {
case 0 :
return 1;
case 1 :
switch (m) {
case -1 : return 0.5 * sqrt(1.-x2);
case 0 : return x;
case 1 : return -sqrt(1.-x2);
};
break;
case 2 :
switch (m) {
case -2 : return 0.125 * (1.0 - x2);
case -1 : return 0.5 * x * sqrt(1.0 - x2);
case 0 : return 0.5*(3.*x2 - 1.);
case 1 : return -3.*x*sqrt(1.-x2);
case 2 : return 3.*(1.-x2);
};
break;
case 3 :
switch (m) {
case -3 : return (1.0/48.0) * (1.0 - x2) * sqrt(1.0 - x2);
case -2 : return 0.125 * x * (1.0 - x2);
case -1 : return 0.125 * (5.0 * x2 - 1.0) * sqrt(1.0 - x2);
case 0 : return 0.5*(5.*x*x2 - 3.*x);
case 1 : return -1.5*(5.*x2-1.)*sqrt(1.-x2);
case 2 : return 15.*x*(1.-x2);
case 3 : return -15.*(1.-x2)*sqrt(1.-x2);
};
break;
case 4 :
switch (m) {
case -4 : return (105.0/40320.0)*(1. - 2.*x2 + x2*x2);
case -3 : return (105.0/5040.0)*x*(1.-x2)*sqrt(1.-x2);
case -2 : return (15.0/720.0)*(7.*x2-1.)*(1.-x2);
case -1 : return 0.125*(7.*x*x2-3.*x)*sqrt(1.-x2);
case 0 : return 0.125*(35.*x2*x2 - 30.*x2 + 3.);
case 1 : return -2.5*(7.*x*x2-3.*x)*sqrt(1.-x2);
case 2 : return 7.5*(7.*x2-1.)*(1.-x2);
case 3 : return -105.*x*(1.-x2)*sqrt(1.-x2);
case 4 : return 105.*(1. - 2.*x2 + x2*x2);
};
break;
};
// Easy special cases
// FIXME: G4Pow doesn't check whether the argument gets too large, which is unsafe! Max is 512.
if(m==l) return (l%2 ? -1. : 1.) *
G4Exp(g4pow->logfactorial(2*l) - g4pow->logfactorial(l)) *
G4Exp(G4Log((1.-x*x)*0.25)*0.5*G4double(l));
if(m==l-1) return x*(2.*G4double(m)+1.)*EvalAssocLegendrePoly(m,m,x);
// if m<0, compute P[l,-m,x] and correct
if (m < 0)
{
G4double complementary_value = EvalAssocLegendrePoly(l, -m, x);
return complementary_value * (m%2==0 ? 1.0 : -1.0) * g4pow->factorial(l+m)/g4pow->factorial(l-m);
}
// See if we have this value cached.
if(cache != NULL && cache->count(l) > 0 && (*cache)[l].count(m) > 0) {
return (*cache)[l][m];
// Iteratively walk up from P[m,m,x] to P[l,m,x]
// prime the pump: P[l<m,m,x] = 0
G4double previous = 0.0;
// prime the pump: P[m,m,x]
G4double current;
if (m == 0) current = 1.0;
else if (m == 1) current = -sqrt((1.0 - (x2)));
else {
current = (m%2==0 ? 1.0 : -1.0) *
G4Exp(g4pow->logfactorial(2*m) - g4pow->logfactorial(m)) *
G4Exp(G4Log((1.0-(x2))*0.25)*0.5*G4double(m));
}
// Otherwise calculate recursively
G4double value = (x*G4double(2*l-1)*EvalAssocLegendrePoly(l-1,m,x) -
(G4double(l+m-1))*EvalAssocLegendrePoly(l-2,m,x))/G4double(l-m);
// If we are working with a cache, cache this value.
if(cache != NULL) {
(*cache)[l][m] = value;
// Work up to P[l,m,x]
for(G4int i=m+1; i<=l; i++)
{
G4double next = (-(G4double(i+m-1))*previous + x*G4double(2*i-1)*current )/G4double(i-m);
previous = current;
current = next;
}
return value;
return current;
}
void G4LegendrePolynomial::BuildUpToOrder(size_t orderMax)
void G4LegendrePolynomial::BuildUpToOrder(std::size_t orderMax)
{
if(orderMax > 30) {
G4cout << "G4LegendrePolynomial::GetCoefficient(): "
@@ -129,11 +146,11 @@ void G4LegendrePolynomial::BuildUpToOrder(size_t orderMax)
return;
}
while(fCoefficients.size() < orderMax+1) { /* Loop checking, 30-Oct-2015, G.Folger */
size_t order = fCoefficients.size();
std::size_t order = fCoefficients.size();
fCoefficients.resize(order+1);
if(order <= 1) fCoefficients[order].push_back(1.);
else {
for(size_t iCoeff = 0; iCoeff < order+1; ++iCoeff) {
for(std::size_t iCoeff = 0; iCoeff < order+1; ++iCoeff) {
if((order % 2) == (iCoeff % 2)) {
G4double coeff = 0;
if(iCoeff <= order-2) coeff -= fCoefficients[order-2][iCoeff/2]*G4double(order-1);
@@ -35,10 +35,18 @@
#include "G4PhysicalConstants.hh"
#include "G4ParticleDefinition.hh"
#include "G4NucleiProperties.hh"
#include "G4IsotopeList.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
G4Pow* G4NuclearRadii::fG4pow = G4Pow::GetInstance();
const G4double fAlpha = 0.5*CLHEP::fine_structure_const*CLHEP::hbarc;
const G4double fInvep = 1.0/CLHEP::eplus;
namespace
{
const G4double llog10 = G4Log(10.);
const G4double fAlpha = 0.5*CLHEP::fine_structure_const*CLHEP::hbarc;
const G4double fInvep = 1.0/CLHEP::eplus;
}
G4double G4NuclearRadii::ExplicitRadius(G4int Z, G4int A)
{
@@ -138,10 +146,13 @@ G4double G4NuclearRadii::RadiusKNGG(G4int A)
G4double G4NuclearRadii::RadiusND(G4int A)
{
G4double R = CLHEP::fermi;
if(1 == A) { return R*0.895; }
// G4double x = R*fG4pow->Z13(A);
// if(A <= 3.) { x *= 0.8; }
// else { x *= 1.7; }
if (1 == A) {
R *= 0.895;
} else {
R *= fG4pow->Z13(A);
if (A <= 3.) { R *= 0.8; }
else { R *= 1.7; }
}
return R;
}
@@ -207,6 +218,38 @@ G4double G4NuclearRadii::CoulombFactor(
return (totTcm > bC) ? 1. - bC/totTcm : 0.0;
}
G4double
G4NuclearRadii::NeutronInelasticShape(G4int Z, G4double ekin)
{
G4double A = (Z < 100) ? aeff[Z] : aeff[100];
G4double elog = G4Log(ekin/CLHEP::GeV)/llog10;
G4double p3 = 0.6 + 13./A - 0.0005*A;
G4double p4 = 7.2449 - 0.018242*A;
G4double p5 = 1.36 + 1.8/A + 0.0005*A;
G4double p6 = 1. + 200./A + 0.02*A;
G4double p7 = 3.0 - (A - 70.)*(A - 200.)/11000.;
G4double firstexp = G4Exp(-p4*(elog + p5));
G4double secondexp = G4Exp(-p6*(elog + p7));
return (1. + p3*firstexp/(1. + firstexp))/(1. + secondexp);
}
G4double
G4NuclearRadii::ProtonInelasticShape(G4int Z, G4double ekin)
{
G4double A = (Z < 100) ? aeff[Z] : aeff[100];
G4double elog = G4Log(ekin/CLHEP::GeV)/llog10;
G4double ff1 = 5.6 - 0.016*A; // slope of the drop at medium energies.
G4double ff2 = 1.37 + 1.37/A; // start of the slope.
G4double ff3 = 0.8 + 18./A - 0.002*A; // stephight
G4double res = (1.0 + ff3*(1.0 - (1.0/(1+G4Exp(-ff1*(elog + ff2))))));
ff1 = 8. - 8./A - 0.008*A; // slope of the rise
ff2 = 2.34 - 5.4/A - 0.0028*A; // start of the rise
res /= (1.0 + G4Exp(-ff1*(elog + ff2)));
return res;
}
const G4double G4NuclearRadii::r0[] = {
1.2,
1.3, 1.3, 1.3, 1.3,1.17,1.54,1.65,1.71, 1.7,1.75, // 1-10
@@ -44,7 +44,7 @@ G4Parton::G4Parton(G4int PDGcode)
if (theDefinition == NULL)
{
G4cout << "Encoding = "<<PDGencoding<<G4endl;
G4String text = "G4Parton::GetDefinition(): Encoding not in particle table";
const G4String& text = "G4Parton::GetDefinition(): Encoding not in particle table";
throw G4HadronicException(__FILE__, __LINE__, text);
}
//
@@ -69,7 +69,7 @@ G4Parton::G4Parton(G4int PDGcode)
}
else {
G4cout << "Encoding = "<<PDGencoding<<G4endl;
G4String text = "G4Parton::GetDefinition(): Particle is not a parton";
const G4String& text = "G4Parton::GetDefinition(): Particle is not a parton";
throw G4HadronicException(__FILE__, __LINE__, text);
}
//
@@ -44,7 +44,7 @@ G4V3DNucleus::~G4V3DNucleus()
const G4V3DNucleus & G4V3DNucleus::operator=(const G4V3DNucleus &)
{
G4String text = "G4V3DNucleus::operator= meant to not be accessible";
const G4String& text = "G4V3DNucleus::operator= meant to not be accessible";
throw G4HadronicException(__FILE__, __LINE__, text);
return *this;
}