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
+18 -2
View File
@@ -1,8 +1,24 @@
# Category phys-lists History
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-11-04 Vladimir Ivantchenko (phys-list-V11-02-03)
- G4PhysListFactory - use std::size_t
## 2024-08-09 Gabriele Cosmo (phys-list-V11-02-02)
- G4PhysListRegistry: fixed compilation on XCode for implicit type conversion.
Minor code cleanup (use of nullptr, G4bool, std::size_t, singleton instance
initialisation). Initialise the instance only the first time it gets created.
## 2024-07-03 Robert Hatcher (phys-list-V11-02-01)
- Add "HPT" extension to support adding G4ThermalNeutrons to extensible physlist factory.
- Changed how base phylist matching is done in G4PhysListRegistry in order to support
"_HP" lists and new "_HPT" extension; requires match to be exact or the remaining part
start with "_" or "+"
## 2024-06-05 Alberto Ribon (phys-lists-V11-02-00)
- G4PhysListFactory : added three new variants of the physics list `Shielding`,
@@ -72,8 +72,8 @@ private:
G4String defName;
std::vector<G4String> listnames_hadr;
std::vector<G4String> listnames_em;
size_t nlists_hadr;
size_t nlists_em;
std::size_t nlists_hadr;
std::size_t nlists_em;
G4int verbose;
G4UImessenger* theMessenger;
};
@@ -23,39 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// -------------------------------------------------------------------
//
// GEANT4 Class header file
//
//
// File name: G4PhysListRegistry
//
// Author R. Hatcher 2014-10-15
//
// Modifications: based on G4PhysicsConstructorRegistry
//
// G4PhysListRegistry
//
// Class Description
// This is a singleton keeping pointers to all physics lists
// Class Description - End
//
// This is a singleton keeping pointers to all physics lists.
// Based on G4PhysicsConstructorRegistry.
//
// Author: R. Hatcher, 2014-10-15
// --------------------------------------------------------------------
#ifndef G4PhysListRegistry_hh
#define G4PhysListRegistry_hh 1
#include <vector>
#include <map>
#include "globals.hh"
#include "globals.hh"
class G4VModularPhysicsList;
class G4VBasePhysListStamper;
class G4PhysListRegistry
{
public:
public:
static G4PhysListRegistry* Instance();
// access
@@ -101,7 +91,7 @@ public:
inline G4String GetSystemDefaultPhysList() const { return systemDefault; }
private:
private:
G4PhysListRegistry();
@@ -123,7 +113,6 @@ private:
// created upon the call of the method
mutable std::vector<G4String> availBasePhysLists;
mutable std::vector<G4String> availExtensions;
};
#endif
@@ -93,14 +93,14 @@ G4PhysListFactory::G4PhysListFactory(G4int ver)
"FTFP_BERT_HPT","FTFP_INCLXX_HPT","QGSP_BERT_HPT","QGSP_BIC_HPT",
"QGSP_BIC_AllHPT","QGSP_INCLXX_HPT","Shielding_HPT","ShieldingLIQMD_HPT",
"ShieldingM_HPT"};
for(size_t i=0; i<nlists_hadr; ++i) {
for (std::size_t i=0; i<nlists_hadr; ++i) {
listnames_hadr.push_back(ss[i]);
}
nlists_em = 12;
G4String s1[12] = {"","_EMV","_EMX","_EMY","_EMZ","_LIV","_PEN",
"__GS","__SS","_EM0","_WVI","__LE"};
for(size_t i=0; i<nlists_em; ++i) {
for (std::size_t i=0; i<nlists_em; ++i) {
listnames_em.push_back(s1[i]);
}
}
@@ -134,7 +134,7 @@ G4VModularPhysicsList*
G4PhysListFactory::GetReferencePhysList(const G4String& name)
{
// analysis on the string
size_t n = name.size();
std::size_t n = name.size();
// last characters in the string
size_t em_opt = 0;
@@ -143,7 +143,7 @@ G4PhysListFactory::GetReferencePhysList(const G4String& name)
// check EM options
if(n > 4) {
em_name = name.substr(n - 4, 4);
for(size_t i=1; i<nlists_em; ++i) {
for (std::size_t i=1; i<nlists_em; ++i) {
if(listnames_em[i] == em_name) {
em_opt = i;
n -= 4;
@@ -247,10 +247,10 @@ G4PhysListFactory::GetReferencePhysList(const G4String& name)
G4bool G4PhysListFactory::IsReferencePhysList(const G4String& name) const
{
G4bool res = false;
size_t n = name.size();
std::size_t n = name.size();
if(n > 4) {
G4String em_name = name.substr(n - 4, 4);
for(size_t i=1; i<nlists_em; ++i) {
for (std::size_t i=1; i<nlists_em; ++i) {
if(listnames_em[i] == em_name) {
n -= 4;
break;
@@ -258,7 +258,7 @@ G4bool G4PhysListFactory::IsReferencePhysList(const G4String& name) const
}
}
G4String had_name = name.substr(0, n);
for(size_t i=0; i<nlists_hadr; ++i) {
for (std::size_t i=0; i<nlists_hadr; ++i) {
if(had_name == listnames_hadr[i]) {
res = true;
break;
@@ -23,24 +23,15 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4PhysListRegistry
//
//
// -------------------------------------------------------------------
//
// GEANT4 Class file
//
// File name: G4PhysListRegistry
//
// Author R. Hatcher 2014-10-15
//
// Modifications: based on G4PhysicsConstructorRegistry
//
//#define G4VERBOSE 1
// Author: R. Hatcher, 2014-10-15
// --------------------------------------------------------------------
#include "G4ios.hh"
#include <iomanip>
#include <algorithm>
#include "G4ios.hh"
#include "G4PhysListRegistry.hh"
#include "G4VModularPhysicsList.hh"
#include "G4PhysListStamper.hh"
@@ -56,41 +47,40 @@
// include this with this compilation unit so static builds pull them in
#include "G4RegisterPhysLists.icc"
G4ThreadLocal G4PhysListRegistry* G4PhysListRegistry::theInstance = 0;
G4ThreadLocal G4PhysListRegistry* G4PhysListRegistry::theInstance = nullptr;
const int doReplace = 0x01; // _ (ReplacePhysics) vs. + (RegisterPhysics)
const int isCtorName = 0x02; // true if actual physCtor name vs. ext name
const G4int doReplace = 0x01; // _ (ReplacePhysics) vs. + (RegisterPhysics)
const G4int isCtorName = 0x02; // true if actual physCtor name vs. ext name
G4PhysListRegistry* G4PhysListRegistry::Instance()
{
if ( 0 == theInstance) {
static G4ThreadLocal G4PhysListRegistry *manager_G4MT_TLS_ = 0;
if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4PhysListRegistry;
G4PhysListRegistry &manager = *manager_G4MT_TLS_;
theInstance = &manager;
if ( nullptr == theInstance) {
theInstance = new G4PhysListRegistry;
// common EM overrides
theInstance->AddPhysicsExtension("EM0","G4EmStandardPhysics");
theInstance->AddPhysicsExtension("EMV","G4EmStandardPhysics_option1");
theInstance->AddPhysicsExtension("EMX","G4EmStandardPhysics_option2");
theInstance->AddPhysicsExtension("EMY","G4EmStandardPhysics_option3");
theInstance->AddPhysicsExtension("EMZ","G4EmStandardPhysics_option4");
theInstance->AddPhysicsExtension("LIV","G4EmLivermorePhysics");
theInstance->AddPhysicsExtension("PEN","G4EmPenelopePhysics");
// the GS EM extension originally required double underscores
// support either one or two as __GS is confusing to users
// same for __SS
theInstance->AddPhysicsExtension("GS" ,"G4EmStandardPhysicsGS");
theInstance->AddPhysicsExtension("_GS","G4EmStandardPhysicsGS");
theInstance->AddPhysicsExtension("SS" ,"G4EmStandardPhysicsSS");
theInstance->AddPhysicsExtension("_SS","G4EmStandardPhysicsSS");
theInstance->AddPhysicsExtension("EM0","G4EmStandardPhysics");
theInstance->AddPhysicsExtension("WVI","G4EmStandardPhysicsWVI");
theInstance->AddPhysicsExtension("LE" ,"G4EmLowEPPhysics");
theInstance->AddPhysicsExtension("_LE","G4EmLowEPPhysics");
theInstance->AddPhysicsExtension("HPT","G4ThermalNeutrons");
}
// common EM overrides
theInstance->AddPhysicsExtension("EM0","G4EmStandardPhysics");
theInstance->AddPhysicsExtension("EMV","G4EmStandardPhysics_option1");
theInstance->AddPhysicsExtension("EMX","G4EmStandardPhysics_option2");
theInstance->AddPhysicsExtension("EMY","G4EmStandardPhysics_option3");
theInstance->AddPhysicsExtension("EMZ","G4EmStandardPhysics_option4");
theInstance->AddPhysicsExtension("LIV","G4EmLivermorePhysics");
theInstance->AddPhysicsExtension("PEN","G4EmPenelopePhysics");
// the GS EM extension originally required double underscores
// support either one or two as __GS is confusing to users
// same for __SS
theInstance->AddPhysicsExtension("GS" ,"G4EmStandardPhysicsGS");
theInstance->AddPhysicsExtension("_GS","G4EmStandardPhysicsGS");
theInstance->AddPhysicsExtension("SS" ,"G4EmStandardPhysicsSS");
theInstance->AddPhysicsExtension("_SS","G4EmStandardPhysicsSS");
theInstance->AddPhysicsExtension("EM0","G4EmStandardPhysics");
theInstance->AddPhysicsExtension("WVI","G4EmStandardPhysicsWVI");
theInstance->AddPhysicsExtension("LE" ,"G4EmLowEPPhysics");
theInstance->AddPhysicsExtension("_LE","G4EmLowEPPhysics");
return theInstance;
}
@@ -134,12 +124,12 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
G4bool allKnown =
DeconstructPhysListName(name,plBase,physExt,physReplace,verbose);
size_t npc = physExt.size();
std::size_t npc = physExt.size();
if ( verbose > 0 ) {
G4cout << "G4PhysListRegistry::GetModularPhysicsList <"
<< name << ">"
<< ", as \"" << plBase << "\" with extensions \"";
for ( size_t ipc = 0; ipc < npc; ++ipc )
for ( std::size_t ipc = 0; ipc < npc; ++ipc )
G4cout << ((physReplace[ipc]&doReplace)?"_":"+") << physExt[ipc];
G4cout << "\"" << G4endl;
}
@@ -148,7 +138,7 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
// couldn't match what the user wanted ...
G4cout << "### G4PhysListRegistry WARNING: " << name
<< " is not known" << G4endl << G4endl;
if ( ! unknownFatal ) return 0;
if ( ! unknownFatal ) return nullptr;
G4ExceptionDescription ED;
ED << "The factory for the physicslist ["<< name << "] does not exist!"
@@ -157,14 +147,14 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
ED << "Could determine no sensible base physics list" << G4endl;
} else {
ED << "One or more of the extensions does not exist [ ";
for ( size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
for ( std::size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
ED << physExt[ipc] << " ";
}
ED << "]" << G4endl;
}
G4Exception("G4PhysListRegistry::GetModularPhysicsList",
"PhysicsList002", FatalException, ED);
return 0;
return nullptr;
}
// if we want this method "const" then the next line becomes more complex
@@ -175,7 +165,7 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
G4PhysicsConstructorRegistry::Instance();
G4int ver = pl->GetVerboseLevel();
pl->SetVerboseLevel(0);
for ( size_t ipc = 0; ipc < npc; ++ipc ) {
for ( std::size_t ipc = 0; ipc < npc; ++ipc ) {
// got back a list of short names, need to use the map to get the
// full physics constructor name
G4String extName = physExt[ipc];
@@ -250,7 +240,7 @@ G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
plBase = "";
physExt.clear();
replace.clear();
bool allKnown = false;
G4bool allKnown = false;
G4String workingName = name;
@@ -297,7 +287,7 @@ G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
physicsExtensions.find(extraName);
G4String pcname = "";
if ( itr != physicsExtensions.end() ) pcname = itr->second;
bool realknown = physConstRegistry->IsKnownPhysicsConstructor(pcname);
G4bool realknown = physConstRegistry->IsKnownPhysicsConstructor(pcname);
if ( ! realknown ) allKnown = false;
#ifdef G4VERBOSE
if ( verb > 2 ) {
@@ -350,25 +340,52 @@ G4bool G4PhysListRegistry::FindLongestMatch(const G4String& workingName,
G4int verb) const
{
bestMatch = "";
bool found = false;
G4bool found = false;
size_t n = validNames.size();
for (size_t i=0; i<n; ++i) {
std::size_t n = validNames.size();
for (std::size_t i=0; i<n; ++i) {
const G4String& testName = validNames[i];
size_t ipos = workingName.find(testName);
std::size_t ipos = workingName.find(testName);
if ( ipos == 0 ) {
if ( testName.size() > bestMatch.size() ) {
bestMatch = testName;
found = true;
if ( verb > 3 ) {
G4cout << " " << searchName << " current best guess: "
<< testName << G4endl;
std::size_t testNameSize = testName.size();
std::size_t workNameSize = workingName.size();
G4bool match = true;
if ( searchName == "base" ) {
// if searching for a valid base impose extra restrictions
// either must exactly match or the next character must be
// one of the standard delimiters of "_" or "+"
if (workNameSize > testNameSize) {
char nextChar = workingName[(G4int)testNameSize];
if ( nextChar != '_' && nextChar != '+' ) match = false;
if ( verb > 3 ) {
G4cout << " " << searchName << " longer "
<< testName << " nextChar " << nextChar << G4endl;
}
}
}
if ( verb > 3 ) {
G4cout << " " << searchName << " match " << (match?"yes":"no")
<< " " << testName << G4endl;
}
if ( match ) {
if ( testName.size() > bestMatch.size() ) {
bestMatch = testName;
found = true;
if ( verb > 3 ) {
G4cout << " " << searchName << " current best guess: "
<< testName << G4endl;
}
} else {
if ( verb > 3 ) {
G4cout << " " << searchName << " match but shorter than previous: "
<< testName << G4endl;
}
}
} else {
if ( verb > 3 ) {
G4cout << " " << searchName << " match but shorter: "
<< testName << G4endl;
}
if ( verb > 3 ) {
G4cout << " " << searchName << " ipos=0 but no match "
<< testName << G4endl;
}
}
} else {
if ( verb > 3 ) {
@@ -417,8 +434,8 @@ void G4PhysListRegistry::PrintAvailablePhysLists() const
<< G4endl;
if ( avail.empty() ) G4cout << "... no registered lists" << G4endl;
else {
size_t n = avail.size();
for (size_t i=0; i<n; ++i ) {
std::size_t n = avail.size();
for (std::size_t i=0; i<n; ++i ) {
G4cout << " [" << std::setw(3) << i << "] "
<< " \"" << avail[i] << "\"" << G4endl;
}
@@ -430,7 +447,7 @@ void G4PhysListRegistry::PrintAvailablePhysLists() const
G4cout << "Replacement mappings in G4PhysListRegistry are:"
<< G4endl;
for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
bool known = physConstRegistry->IsKnownPhysicsConstructor(itr->second);
G4bool known = physConstRegistry->IsKnownPhysicsConstructor(itr->second);
G4cout << " " << std::setw(10) << itr->first << " => "
<< std::setw(30) << itr->second << " "