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
@@ -6,6 +6,15 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-08-21 Gabriele Cosmo (hadr-lend-V11-02-05)
- Fixed reported Coverity defects for:
o pointless expression condition in ptwXY_div_ptwXY() operator;
o dead code statement in MCGIDI_angularEnergy_parsePointwiseFromTOM() and
in MCGIDI_energyAngular_linear_parseFromTOM().
## 2024-08-14 Gabriele Cosmo (hadr-lend-V11-02-04)
- Fixed reported Coverity defects for use of std::move() and const std::string&.
## 2024-05-02 Gabriele Cosmo (hadr-lend-V11-02-03)
- Fixed compilation warnings for potentially initialised local variables in
ptwXY_createFromFunctionZeroCrossing().
@@ -49,35 +49,35 @@ class G4GIDI {
G4int init( G4int ip );
public:
G4GIDI( G4int ip, std::string &dataDirectory );
G4GIDI( G4int ip, const std::string &dataDirectory );
G4GIDI( G4int ip, std::list<std::string> &dataDirectory );
~G4GIDI( );
G4int numberOfDataDirectories( void );
G4int addDataDirectory( std::string &dataDirectory );
G4int removeDataDirectory( std::string &dataDirectory );
G4int addDataDirectory( const std::string &dataDirectory );
G4int removeDataDirectory( const std::string &dataDirectory );
std::string getDataDirectoryAtIndex( G4int index );
std::vector<std::string> *getDataDirectories( void );
G4bool isThisDataAvailable( std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
G4bool isThisDataAvailable( std::string &lib_name, std::string &targetName );
G4bool isThisDataAvailable( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
G4bool isThisDataAvailable( const std::string &lib_name, const std::string &targetName );
char *dataFilename( std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
char *dataFilename( std::string &lib_name, std::string &targetName );
char *dataFilename( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0 );
char *dataFilename( const std::string &lib_name, const std::string &targetName );
std::vector<std::string> *getNamesOfAvailableLibraries( G4int iZ, G4int iA, G4int iM = 0 );
std::vector<std::string> *getNamesOfAvailableLibraries( std::string &targetName );
std::vector<std::string> *getNamesOfAvailableLibraries( const std::string &targetName );
std::vector<std::string> *getNamesOfAvailableTargets( void );
G4GIDI_target *readTarget( std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0, G4bool bind = true );
G4GIDI_target *readTarget( std::string &lib_name, std::string &targetName, G4bool bind = true );
G4GIDI_target *readTarget( const std::string &lib_name, G4int iZ, G4int iA, G4int iM = 0, G4bool bind = true );
G4GIDI_target *readTarget( const std::string &lib_name, const std::string &targetName, G4bool bind = true );
G4GIDI_target *getAlreadyReadTarget( G4int iZ, G4int iA, G4int iM = 0 );
G4GIDI_target *getAlreadyReadTarget( std::string &targetName );
G4GIDI_target *getAlreadyReadTarget( const std::string &targetName );
G4int freeTarget( G4int iZ, G4int iA, G4int iM = 0 );
G4int freeTarget( std::string &targetSymbol );
G4int freeTarget( const std::string &targetSymbol );
G4int freeTarget( G4GIDI_target *target );
std::vector<std::string> *getListOfReadTargetsNames( void );
@@ -41,7 +41,7 @@ class G4GIDI_map {
GIDI::statusMessageReporting smr;
GIDI::MCGIDI_map *map;
G4GIDI_map( std::string &dataDirectory );
G4GIDI_map( const std::string &dataDirectory );
~G4GIDI_map( );
std::string path( void );
@@ -80,7 +80,7 @@ class G4LENDManager
return lend_manager;
};
G4GIDI_target* GetLENDTarget( G4ParticleDefinition* , G4String , G4int iZ , G4int iA , G4int iM = 0 );
G4GIDI_target* GetLENDTarget( G4ParticleDefinition* , const G4String& , G4int iZ , G4int iA , G4int iM = 0 );
std::vector< G4String > IsLENDTargetAvailable( G4ParticleDefinition* , G4int iZ , G4int iA , G4int iM = 0 );
G4int GetNucleusEncoding ( G4int iZ , G4int iA , G4int iM );
@@ -48,7 +48,7 @@ class G4LENDUsedTarget
public:
G4LENDUsedTarget( G4ParticleDefinition* pd , G4String Evaluation , G4int iZ , G4int iA , G4int iM = 0 )
G4LENDUsedTarget( G4ParticleDefinition* pd , const G4String& Evaluation , G4int iZ , G4int iA , G4int iM = 0 )
: allow_nat ( false )
, allow_anything ( false )
, min_Z ( 0 )
@@ -74,32 +74,32 @@ class G4LENDUsedTarget
searchTarget();
}
~G4LENDUsedTarget(){;};
~G4LENDUsedTarget(){;}
void AllowNat()
{
allow_nat = true;
searchTarget();
};
}
void AllowAny()
{
allow_anything = true;
searchTarget();
};
}
G4int GetWantedZ(){ return wanted_Z; };
G4int GetWantedA(){ return wanted_A; };
G4int GetWantedM(){ return wanted_M; };
G4int GetWantedZ() const { return wanted_Z; }
G4int GetWantedA() const { return wanted_A; }
G4int GetWantedM() const { return wanted_M; }
G4int GetActualZ(){ return actual_Z; };
G4int GetActualA(){ return actual_A; };
G4int GetActualM(){ return actual_M; };
G4int GetActualZ() const { return actual_Z; }
G4int GetActualA() const { return actual_A; }
G4int GetActualM() const { return actual_M; }
G4String GetWantedEvaluation(){ return wanted_Evaluation; };
G4String GetActualEvaluation(){ return actual_Evaluation; };
const G4String& GetWantedEvaluation() const { return wanted_Evaluation; }
const G4String& GetActualEvaluation() const { return actual_Evaluation; }
G4GIDI_target* GetTarget(){ return target; };
G4GIDI_target* GetTarget() const { return target; }
private:
@@ -34,7 +34,7 @@ using namespace GIDI;
/*
***************************************************************
*/
G4GIDI::G4GIDI( G4int ip, string &dataDirectory ) {
G4GIDI::G4GIDI( G4int ip, const string &dataDirectory ) {
init( ip );
addDataDirectory( dataDirectory );
@@ -103,7 +103,7 @@ G4int G4GIDI::numberOfDataDirectories( void ) {
/*
***************************************************************
*/
G4int G4GIDI::addDataDirectory( string &dataDirectory ) {
G4int G4GIDI::addDataDirectory( const string &dataDirectory ) {
for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter ) {
if( (*iter)->path( ) == dataDirectory ) return( 0 );
@@ -117,7 +117,7 @@ G4int G4GIDI::addDataDirectory( string &dataDirectory ) {
/*
***************************************************************
*/
G4int G4GIDI::removeDataDirectory( string &dataDirectory ) {
G4int G4GIDI::removeDataDirectory( const string &dataDirectory ) {
for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter ) {
if( dataDirectory == (*iter)->path( ) ) {
@@ -156,7 +156,7 @@ vector<string> *G4GIDI::getDataDirectories( void ) {
/*
***************************************************************
*/
G4bool G4GIDI::isThisDataAvailable( string &lib_name, G4int iZ, G4int iA, G4int iM ) {
G4bool G4GIDI::isThisDataAvailable( const string &lib_name, G4int iZ, G4int iA, G4int iM ) {
G4bool b;
char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
@@ -170,7 +170,7 @@ G4bool G4GIDI::isThisDataAvailable( string &lib_name, G4int iZ, G4int iA, G4int
/*
***************************************************************
*/
G4bool G4GIDI::isThisDataAvailable( string &lib_name, string &targetName ) {
G4bool G4GIDI::isThisDataAvailable( const string &lib_name, const string &targetName ) {
char *path = dataFilename( lib_name, targetName );
@@ -183,7 +183,7 @@ G4bool G4GIDI::isThisDataAvailable( string &lib_name, string &targetName ) {
/*
***************************************************************
*/
char *G4GIDI::dataFilename( string &lib_name, G4int iZ, G4int iA, G4int iM ) {
char *G4GIDI::dataFilename( const string &lib_name, G4int iZ, G4int iA, G4int iM ) {
char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM ), *fileName;
@@ -196,7 +196,7 @@ char *G4GIDI::dataFilename( string &lib_name, G4int iZ, G4int iA, G4int iM ) {
/*
***************************************************************
*/
char *G4GIDI::dataFilename( string &lib_name, string &targetSymbol ) {
char *G4GIDI::dataFilename( const string &lib_name, const string &targetSymbol ) {
char *path;
@@ -223,7 +223,7 @@ vector<string> *G4GIDI::getNamesOfAvailableLibraries( G4int iZ, G4int iA, G4int
/*
***************************************************************
*/
vector<string> *G4GIDI::getNamesOfAvailableLibraries( string &targetName ) {
vector<string> *G4GIDI::getNamesOfAvailableLibraries( const string &targetName ) {
vector<string> *listOfLibraries = new vector<string>( );
@@ -259,7 +259,7 @@ vector<string> *G4GIDI::getNamesOfAvailableTargets( void ) {
/*
***************************************************************
*/
G4GIDI_target *G4GIDI::readTarget( string &lib_name, G4int iZ, G4int iA, G4int iM, G4bool bind ) {
G4GIDI_target *G4GIDI::readTarget( const string &lib_name, G4int iZ, G4int iA, G4int iM, G4bool bind ) {
char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
G4GIDI_target *target;
@@ -273,7 +273,7 @@ G4GIDI_target *G4GIDI::readTarget( string &lib_name, G4int iZ, G4int iA, G4int i
/*
***************************************************************
*/
G4GIDI_target *G4GIDI::readTarget( string &lib_name, string &targetName, G4bool bind ) {
G4GIDI_target *G4GIDI::readTarget( const string &lib_name, const string &targetName, G4bool bind ) {
for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
if( (*iter_targets)->name == targetName ) return( nullptr );
@@ -303,7 +303,7 @@ G4GIDI_target *G4GIDI::getAlreadyReadTarget( G4int iZ, G4int iA, G4int iM ) {
/*
***************************************************************
*/
G4GIDI_target *G4GIDI::getAlreadyReadTarget( string &targetSymbol ) {
G4GIDI_target *G4GIDI::getAlreadyReadTarget( const string &targetSymbol ) {
for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
if( ( (*iter_targets)->name == targetSymbol ) ) return( *iter_targets );
@@ -341,7 +341,7 @@ G4int G4GIDI::freeTarget( G4int iZ, G4int iA, G4int iM ) {
/*
***************************************************************
*/
G4int G4GIDI::freeTarget( string &targetSymbol ) {
G4int G4GIDI::freeTarget( const string &targetSymbol ) {
for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
if( (*iter_targets)->name == targetSymbol ) return( freeTarget( *iter_targets ) );
@@ -34,7 +34,7 @@ using namespace GIDI;
/*
***************************************************************
*/
G4GIDI_map::G4GIDI_map( std::string &dataDirectory ) {
G4GIDI_map::G4GIDI_map( const std::string &dataDirectory ) {
smr_initialize( &smr, smr_status_Ok, 0 );
map = MCGIDI_map_readFile( &smr, NULL, dataDirectory.c_str( ) );
@@ -185,15 +185,13 @@ G4LENDManager::~G4LENDManager()
{
// deleting target
for ( std::vector < lend_target >::iterator
it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
for ( auto it = v_lend_target.cbegin() ; it != v_lend_target.cend() ; ++it )
{
(*it).lend->freeTarget( it->target );
}
// deleting lend
for ( std::map < G4ParticleDefinition* , G4GIDI* >::iterator
it = proj_lend_map.begin() ; it != proj_lend_map.end() ; it++ )
for ( auto it = proj_lend_map.cbegin() ; it != proj_lend_map.cend() ; ++it )
{
delete it->second;
}
@@ -205,7 +203,7 @@ G4LENDManager::~G4LENDManager()
G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4String evaluation , G4int iZ , G4int iA , G4int iM )
G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , const G4String& evaluation , G4int iZ , G4int iA , G4int iM )
{
G4GIDI_target* anLENDTarget = NULL;
@@ -217,8 +215,7 @@ G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4Stri
G4int iTarg = GetNucleusEncoding( iZ , iA , iM );
// Searching in current map
for ( std::vector < lend_target >::iterator
it = v_lend_target.begin() ; it != v_lend_target.end() ; it++ )
for ( auto it = v_lend_target.cbegin() ; it != v_lend_target.cend() ; ++it )
{
if ( it->proj == proj && it->target_code == iTarg && it->evaluation == evaluation )
{
@@ -228,7 +225,7 @@ G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4Stri
}
if ( proj_lend_map.find ( proj ) == proj_lend_map.end() ) {
if ( proj_lend_map.find ( proj ) == proj_lend_map.cend() ) {
G4cout << proj->GetParticleName() << " is not supported by this LEND library." << G4endl;
return anLENDTarget; // return NULL
}
@@ -252,7 +249,7 @@ G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4Stri
new_target.evaluation = evaluation;
new_target.target_code = iTarg;
v_lend_target.push_back( new_target );
v_lend_target.push_back( std::move(new_target) );
// found EXACT
return anLENDTarget;
@@ -275,8 +272,7 @@ G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4Stri
{
G4cout << " However you can use following evaluation(s) for the target. " << G4endl;
std::vector< std::string >::iterator its;
for ( its = available->begin() ; its != available->end() ; its++ )
for ( auto its = available->cbegin() ; its != available->cend() ; ++its )
G4cout << *its << G4endl;
G4cout << G4endl;
@@ -298,8 +294,7 @@ G4GIDI_target* G4LENDManager::GetLENDTarget( G4ParticleDefinition* proj , G4Stri
if ( verboseLevel > 1 ) {
G4cout << " However you can use following evaluation(s) for natural abundace of the target. " << G4endl;
std::vector< std::string >::iterator its;
for ( its = available_nat->begin() ; its != available_nat->end() ; its++ )
for ( auto its = available_nat->cbegin() ; its != available_nat->cend() ; ++its )
G4cout << *its << G4endl;
G4cout << G4endl;
}
@@ -319,7 +314,7 @@ std::vector< G4String > G4LENDManager::IsLENDTargetAvailable ( G4ParticleDefinit
{
std::vector< G4String > vEvaluation;
if ( proj_lend_map.find ( proj ) == proj_lend_map.end() )
if ( proj_lend_map.find ( proj ) == proj_lend_map.cend() )
{
G4cout << proj->GetParticleName() << " is not supported by this LEND." << G4endl;
return vEvaluation; // return empty
@@ -329,8 +324,7 @@ std::vector< G4String > G4LENDManager::IsLENDTargetAvailable ( G4ParticleDefinit
std::vector< std::string >* available = xlend->getNamesOfAvailableLibraries( iZ, iA , iM );
if ( available->size() > 0 ) {
std::vector< std::string >::iterator its;
for ( its = available->begin() ; its != available->end() ; its++ )
for ( auto its = available->cbegin() ; its != available->cend() ; ++its )
vEvaluation.push_back ( *its );
}
delete available;
@@ -409,7 +403,7 @@ G4double G4LENDManager::GetExcitationEnergyOfExcitedIsomer( G4int iZ , G4int iA
G4double EE = 0.0;
G4int nucCode = GetNucleusEncoding( iZ , iA , iM );
auto it = mExcitationEnergy.find( nucCode );
if ( it != mExcitationEnergy.end() ) {
if ( it != mExcitationEnergy.cend() ) {
EE = it->second;
} else {
if ( iM == 0 ) {
@@ -136,7 +136,6 @@ static int MCGIDI_angularEnergy_parsePointwiseFromTOM( statusMessageReporting *s
if( ( pdfXY1 = MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf( smr, XYs, interpolationXY, energyOutProbabilityUnits ) ) == NULL ) goto err;
y = ptwXY_integrateDomain( pdfXY1, &status );
if( ( status = ptwXY_setValueAtX( pdfXY2, XYs->value, y ) ) != nfu_Okay ) goto errA;
if( status != nfu_Okay ) goto errA;
if( y == 0 ) {
if( ( status = ptwXY_add_double( pdfXY1, 0.5 ) ) != nfu_Okay ) goto errA;
@@ -142,7 +142,6 @@ static int MCGIDI_energyAngular_linear_parseFromTOM( statusMessageReporting *smr
if( ( pdfXY1 = MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf( smr, XYs, interpolationXY, multiplicityProbabilityUnits ) ) == NULL ) goto err;
y = ptwXY_integrateDomain( pdfXY1, &status );
if( ( status = ptwXY_setValueAtX( pdfXY2, energyOutFactor * XYs->value, y ) ) != nfu_Okay ) goto errA;
if( status != nfu_Okay ) goto errA;
if( y == 0 ) {
if( ( status = ptwXY_add_double( pdfXY1, 0.5 ) ) != nfu_Okay ) goto errA;
@@ -298,7 +298,7 @@ ptwXYPoints *ptwXY_div_ptwXY( ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_stat
*status = nfu_otherInterpolation;
if( ptwXY1->interpolation == ptwXY_interpolationOther ) return( NULL );
if( ptwXY2->interpolation == ptwXY_interpolationOther ) return( NULL );
if( ( ptwXY1->interpolation == ptwXY_interpolationFlat ) || ( ptwXY1->interpolation == ptwXY_interpolationFlat ) )
if( ( ptwXY1->interpolation == ptwXY_interpolationFlat ) || ( ptwXY2->interpolation == ptwXY_interpolationFlat ) )
return( ptwXY_div_ptwXY_forFlats( ptwXY1, ptwXY2, status, safeDivide ) );
if( ( *status = ptwXY_areDomainsMutual( ptwXY1, ptwXY2 ) ) != nfu_Okay ) return( NULL );