Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -14,6 +14,27 @@ code and to keep track of all tags.
|
||||
* Please list in reverse chronological order (last date on top)
|
||||
---------------------------------------------------------------
|
||||
|
||||
16 June 2017 Vladimir Ivanchenko (hadr-util-V10-03-04)
|
||||
--------------------------------------------------------
|
||||
- G4NuclearPolarization - improved printout
|
||||
|
||||
28 April 2017 Tatsumi Koi (hadr-util-V10-03-03)
|
||||
--------------------------------------------------------
|
||||
- Fix warning message in previous tag
|
||||
|
||||
14 April 2017 Tatsumi Koi (hadr-util-V10-03-02)
|
||||
--------------------------------------------------------
|
||||
- Fix warning message in previous tag
|
||||
|
||||
10 April 2017 Tatsumi Koi (hadr-util-V10-03-01)
|
||||
--------------------------------------------------------
|
||||
- Introduce G4HadronicDeveloperParameter which helps
|
||||
sharing a parameter between developer and experineced user
|
||||
|
||||
08 March 2017 Vladimir Ivanchenko (hadr-util-V10-03-00)
|
||||
--------------------------------------------------------
|
||||
- G4GHEKinematicsVector - fixed variable shadowing
|
||||
|
||||
5 December 2016 Dennis Wright (hadr-util-V10-02-01)
|
||||
--------------------------------------------------------
|
||||
- G4Nucleus::GetThermalNucleus: fix mistake in branch on total energy
|
||||
|
||||
@@ -671,10 +671,10 @@ class G4GHEKinematicsVector
|
||||
}
|
||||
|
||||
inline
|
||||
void Print( G4int L)
|
||||
void Print( G4int LLL)
|
||||
{
|
||||
G4cout << "G4GHEKinematicsVector: "
|
||||
<< L << " " << momentum.x() << " " << momentum.y() << " " << momentum.z() << " "
|
||||
<< LLL << " " << momentum.x() << " " << momentum.y() << " " << momentum.z() << " "
|
||||
<< energy << " " << kineticEnergy << " " << mass << " " << charge << " "
|
||||
<< timeOfFlight << " " << side << " " << flag << " " << code << particleDef << G4endl;
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef G4HadronicDeveloperParameters_h
|
||||
#define G4HadronicDeveloperParameters_h
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
#include<map>
|
||||
#include<string>
|
||||
#include<cfloat>
|
||||
|
||||
|
||||
class G4HadronicDeveloperParameters
|
||||
{
|
||||
public:
|
||||
static G4HadronicDeveloperParameters& GetInstance();
|
||||
|
||||
//protected:
|
||||
private:
|
||||
G4HadronicDeveloperParameters();
|
||||
G4HadronicDeveloperParameters( const 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 );
|
||||
|
||||
//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 );
|
||||
|
||||
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 );
|
||||
|
||||
std::map<std::string,G4bool> b_values;
|
||||
std::map<std::string,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<std::string,G4double> values;
|
||||
std::map<std::string,const G4double> defaults;
|
||||
std::map<std::string,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 );
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -91,7 +91,6 @@ public:
|
||||
G4bool operator==(const G4NuclearPolarization &right) const;
|
||||
G4bool operator!=(const G4NuclearPolarization &right) const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&, const G4NuclearPolarization*);
|
||||
friend std::ostream& operator<<(std::ostream&, const G4NuclearPolarization&);
|
||||
|
||||
private:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: sources.cmake 92101 2015-08-18 09:06:50Z gcosmo $
|
||||
# $Id: sources.cmake 103898 2017-05-03 08:25:03Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -53,6 +53,7 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_util
|
||||
G4HadSignalHandler.hh
|
||||
G4HadTmpUtil.hh
|
||||
G4HadronicDeprecate.hh
|
||||
G4HadronicDeveloperParameters.hh
|
||||
G4HadronicException.hh
|
||||
G4HadronicWhiteBoard.hh
|
||||
G4IsoResult.hh
|
||||
@@ -71,6 +72,7 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_util
|
||||
G4HadSecondary.cc
|
||||
G4HadSignalHandler.cc
|
||||
G4HadTmpUtil.cc
|
||||
G4HadronicDeveloperParameters.cc
|
||||
G4HadronicWhiteBoard.cc
|
||||
G4IsoResult.cc
|
||||
G4LightMedia.cc
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
#include"G4HadronicDeveloperParameters.hh"
|
||||
|
||||
G4HadronicDeveloperParameters& G4HadronicDeveloperParameters::GetInstance(){
|
||||
static G4HadronicDeveloperParameters instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
G4HadronicDeveloperParameters::G4HadronicDeveloperParameters(){
|
||||
}
|
||||
|
||||
G4HadronicDeveloperParameters::G4HadronicDeveloperParameters( const G4HadronicDeveloperParameters& ){
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string 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() ) {
|
||||
status = true;
|
||||
b_defaults.insert( std::pair<std::string, const G4bool>( name , value ) );
|
||||
b_values.insert( std::pair<std::string, G4bool>( name , value ) );
|
||||
} else {
|
||||
/*error*/
|
||||
issue_is_already_defined( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string 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() ) {
|
||||
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 ) ) );
|
||||
} else {
|
||||
/*error*/
|
||||
issue_is_already_defined( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::SetDefault( const std::string 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() ) {
|
||||
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 ) ) );
|
||||
} else {
|
||||
/*error*/
|
||||
issue_is_already_defined( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4bool value ){
|
||||
G4bool status = false;
|
||||
const std::map<std::string,G4bool>::iterator it = b_values.find( name );
|
||||
if ( it != b_values.end() ) {
|
||||
if ( it->second == b_defaults.find(name)->second ) {
|
||||
status = true;
|
||||
it->second = value;
|
||||
} else {
|
||||
/*change more than once*/
|
||||
issue_has_changed( name );
|
||||
}
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4int value ){
|
||||
G4bool status = false;
|
||||
const std::map<std::string,G4int>::iterator it = i_values.find( name );
|
||||
if ( it != i_values.end() ) {
|
||||
if ( it->second == i_defaults.find(name)->second ) {
|
||||
if ( check_value_within_limits( i_limits.find(name)->second , value ) ) {
|
||||
/*value is OK*/
|
||||
status = true;
|
||||
it->second = value;
|
||||
} else {
|
||||
/*Value is outside of valid range*/
|
||||
issue_non_eligible_value( name );
|
||||
}
|
||||
} else {
|
||||
/*change more than once*/
|
||||
issue_has_changed( name );
|
||||
}
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Set( const std::string name , const G4double value ){
|
||||
G4bool status = false;
|
||||
const std::map<std::string,G4double>::iterator it = values.find( name );
|
||||
if ( it != values.end() ) {
|
||||
if ( it->second == defaults.find(name)->second ) {
|
||||
if ( check_value_within_limits( limits.find(name)->second , value ) ) {
|
||||
/*value is OK*/
|
||||
status = true;
|
||||
it->second = value;
|
||||
} else {
|
||||
/*Value is outside of valid range*/
|
||||
issue_non_eligible_value( name );
|
||||
}
|
||||
} else {
|
||||
/*change more than once*/
|
||||
issue_has_changed( name );
|
||||
}
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4bool& value ) {
|
||||
G4bool status = false;
|
||||
const std::map<std::string,const G4bool>::iterator it = b_defaults.find( name );
|
||||
if ( it != b_defaults.end() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4int& value ) {
|
||||
G4bool status = false;
|
||||
const std::map<std::string,const G4int>::iterator it = i_defaults.find( name );
|
||||
if ( it != i_defaults.end() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::GetDefault( const std::string name , G4double& value ) {
|
||||
G4bool status = false;
|
||||
const std::map<std::string,const G4double>::iterator it = defaults.find( name );
|
||||
if ( it != defaults.end() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4double& value ) {
|
||||
return get( name , value );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4double& value ) {
|
||||
return get( name , value , true );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::get( const std::string 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() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
if ( check_change && value != b_defaults.find(name)->second ) {
|
||||
//Parameter "name" has changed from default
|
||||
issue_is_modified( name );
|
||||
}
|
||||
} else {
|
||||
//Parameter of "name" does not exist
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4int& value ) {
|
||||
return get( name , value );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4int& value ) {
|
||||
return get( name , value , true );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::get( const std::string 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() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
if ( check_change && value != i_defaults.find(name)->second ) {
|
||||
//Parameter "name" has changed from default
|
||||
issue_is_modified( name );
|
||||
}
|
||||
} else {
|
||||
//Parameter of "name" does not exist
|
||||
issue_no_param( name );
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::Get( const std::string name , G4bool& value ) {
|
||||
return get( name , value );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::DeveloperGet( const std::string name , G4bool& value ) {
|
||||
return get( name , value , true );
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::get( const std::string name , G4double& value , G4bool check_change ) {
|
||||
G4bool status = false;
|
||||
const std::map<std::string,G4double>::iterator it = values.find( name );
|
||||
if ( it != values.end() ) {
|
||||
status = true;
|
||||
value = it->second;
|
||||
if ( check_change && value != defaults.find(name)->second ) {
|
||||
/*Parameter "name" has changed from default*/
|
||||
issue_is_modified( name );
|
||||
}
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
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() ) {
|
||||
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() ) {
|
||||
G4cout << "G4HadronicDeveloperParameters: "
|
||||
<< "name = " << name
|
||||
<< ", default value = " << i_defaults.find( name )->second
|
||||
<< ", lower limit = " << i_limits.find( name )->second.first
|
||||
<< ", upper limit = " << i_limits.find( name )->second.second
|
||||
<< ", current value = " << i_values.find( name )->second
|
||||
<< "." << G4endl;
|
||||
} else if ( values.find( name ) != values.end() ) {
|
||||
G4cout << "G4HadronicDeveloperParameters: "
|
||||
<< "name = " << name
|
||||
<< ", default value = " << defaults.find( name )->second
|
||||
<< ", lower limit = " << limits.find( name )->second.first
|
||||
<< ", upper limit = " << limits.find( name )->second.second
|
||||
<< ", current value = " << values.find( name )->second
|
||||
<< "." << G4endl;
|
||||
} else {
|
||||
/*Parameter of "name" does not exist*/
|
||||
issue_no_param( name );
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::check_value_within_limits( std::pair<const G4double,const G4double>& alimits , const G4double value ){
|
||||
if ( alimits.first <= value && value <= alimits.second ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4HadronicDeveloperParameters::check_value_within_limits( std::pair<const G4int,const G4int>& alimits , const G4int value ){
|
||||
if ( alimits.first <= value && value <= alimits.second ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void G4HadronicDeveloperParameters::issue_no_param( const std::string& name ){
|
||||
std::string text("Parameter ");
|
||||
text += name;
|
||||
text += " does not exist.";
|
||||
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_001", FatalException , text.c_str() );
|
||||
}
|
||||
|
||||
void G4HadronicDeveloperParameters::issue_has_changed( const std::string& name ) {
|
||||
std::string text("Parameter ");
|
||||
text += name;
|
||||
text += " has already been changed once.";
|
||||
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_002", FatalException , text.c_str() );
|
||||
}
|
||||
void G4HadronicDeveloperParameters::issue_non_eligible_value( const std::string& name ) {
|
||||
std::string text("The value of the parameter ");
|
||||
text += name;
|
||||
text += " is outside the allowable range.";
|
||||
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_003", FatalException , text.c_str() );
|
||||
}
|
||||
void G4HadronicDeveloperParameters::issue_is_already_defined( const std::string& name ) {
|
||||
std::string text("Parameter ");
|
||||
text += name;
|
||||
text += " is already defined.";
|
||||
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_004", FatalException , text.c_str() );
|
||||
}
|
||||
void G4HadronicDeveloperParameters::issue_is_modified( const std::string& name ) {
|
||||
std::string text("Parameter ");
|
||||
text += name;
|
||||
text += " has changed from default value.";
|
||||
G4Exception( "G4HadronicDeveloperParameters" , "HadDevPara_005", JustWarning , text.c_str() );
|
||||
}
|
||||
@@ -57,23 +57,20 @@ G4bool G4NuclearPolarization::operator!=(const G4NuclearPolarization &right) con
|
||||
return (fPolarization != right.fPolarization);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const G4NuclearPolarization* p)
|
||||
std::ostream& operator<<(std::ostream& out, const G4NuclearPolarization& p)
|
||||
{
|
||||
out << " P = [ { ";
|
||||
for(size_t k=0; k<p->fPolarization.size(); ++k) {
|
||||
if(k>0) { out << " }, { "; }
|
||||
for(size_t kappa=0; kappa<p->fPolarization[k].size(); ++kappa) {
|
||||
if(kappa > 0) { out << ", "; }
|
||||
out << p->fPolarization[k][kappa].real() << " + "
|
||||
<< p->fPolarization[k][kappa].imag() << "*i";
|
||||
out << " P = [ {";
|
||||
size_t kk = p.fPolarization.size();
|
||||
for(size_t k=0; k<kk; ++k) {
|
||||
if(k>0) { out << " {"; }
|
||||
size_t kpmax = (p.fPolarization[k]).size();
|
||||
for(size_t kappa=0; kappa<kpmax; ++kappa) {
|
||||
if(kappa > 0) { out << "} {"; }
|
||||
out << p.fPolarization[k][kappa].real() << " + "
|
||||
<< p.fPolarization[k][kappa].imag() << "*i";
|
||||
}
|
||||
if(k+1 < kk) { out << "}" << G4endl; }
|
||||
}
|
||||
out << " } ]" << G4endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const G4NuclearPolarization& np)
|
||||
{
|
||||
out << &np;
|
||||
out << "} ]" << G4endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user