Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PhysListFactory.cc 83413 2014-08-21 15:21:43Z gcosmo $
// $Id: G4PhysListFactory.cc 92863 2015-09-18 12:44:13Z gcosmo $
//
//---------------------------------------------------------------------------
//
@@ -52,6 +52,7 @@
#include "QGSP_BERT_HP.hh"
#include "QGSP_BIC.hh"
#include "QGSP_BIC_HP.hh"
#include "QGSP_BIC_AllHP.hh"
#include "QGSP_FTFP_BERT.hh"
#include "QGS_BIC.hh"
#include "QGSP_INCLXX.hh"
@@ -64,25 +65,26 @@
#include "G4EmStandardPhysics_option2.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4EmStandardPhysicsGS.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmPenelopePhysics.hh"
G4PhysListFactory::G4PhysListFactory()
: defName("FTFP_BERT"),verbose(1)
{
nlists_hadr = 20;
G4String ss[20] = {
nlists_hadr = 21;
G4String ss[21] = {
"FTFP_BERT","FTFP_BERT_TRV","FTFP_BERT_HP","FTFP_INCLXX",
"FTFP_INCLXX_HP","FTF_BIC", "LBE","QBBC",
"QGSP_BERT","QGSP_BERT_HP","QGSP_BIC","QGSP_BIC_HP",
"QGSP_BERT","QGSP_BERT_HP","QGSP_BIC","QGSP_BIC_HP","QGSP_BIC_AllHP",
"QGSP_FTFP_BERT","QGSP_INCLXX","QGSP_INCLXX_HP","QGS_BIC",
"Shielding","ShieldingLEND","ShieldingM","NuBeam"};
for(size_t i=0; i<nlists_hadr; ++i) {
listnames_hadr.push_back(ss[i]);
}
nlists_em = 7;
G4String s1[7] = {"","_EMV","_EMX","_EMY","_EMZ","_LIV","_PEN"};
nlists_em = 8;
G4String s1[8] = {"","_EMV","_EMX","_EMY","_EMZ","_LIV","_PEN","__GS"};
for(size_t i=0; i<nlists_em; ++i) {
listnames_em.push_back(s1[i]);
}
@@ -154,6 +156,7 @@ G4PhysListFactory::GetReferencePhysList(const G4String& name)
else if(had_name == "QGSP_BERT_HP") {p = new QGSP_BERT_HP(verbose);}
else if(had_name == "QGSP_BIC") {p = new QGSP_BIC(verbose);}
else if(had_name == "QGSP_BIC_HP") {p = new QGSP_BIC_HP(verbose);}
else if(had_name == "QGSP_BIC_AllHP") {p = new QGSP_BIC_AllHP(verbose);}
else if(had_name == "QGSP_FTFP_BERT") {p = new QGSP_FTFP_BERT(verbose);}
else if(had_name == "QGSP_INCLXX") {p = new QGSP_INCLXX(verbose);}
else if(had_name == "QGSP_INCLXX_HP") {p = new QGSP_INCLXX_HP(verbose);}
@@ -185,6 +188,8 @@ G4PhysListFactory::GetReferencePhysList(const G4String& name)
p->ReplacePhysics(new G4EmLivermorePhysics(verbose));
} else if(6 == em_opt) {
p->ReplacePhysics(new G4EmPenelopePhysics(verbose));
} else if(7 == em_opt) {
p->ReplacePhysics(new G4EmStandardPhysicsGS(verbose));
}
}
p->SetVerboseLevel(ver);
@@ -42,42 +42,27 @@
namespace g4alt {
G4PhysListFactory::G4PhysListFactory()
: defName("FTFP_BERT"), verbose(1)
{
}
G4PhysListFactory::~G4PhysListFactory()
{}
void G4PhysListFactory::SetDefaultReferencePhysList(const G4String& name)
{
return G4PhysListRegistry::Instance()->SetUserDefaultPhysList(name);
}
G4VModularPhysicsList*
G4PhysListFactory::ReferencePhysList()
{
// instantiate PhysList by environment variable "PHYSLIST"
G4String name = "";
char* path = getenv("PHYSLIST");
if (path) {
name = G4String(path);
} else {
name = defName;
G4cout << "### g4alt::G4PhysListFactory WARNING: "
<< " environment variable PHYSLIST is not defined"
<< G4endl
<< " Default Physics Lists " << name
<< " is instantiated"
<< G4endl;
}
return GetReferencePhysList(name);
return G4PhysListRegistry::Instance()->GetModularPhysicsListFromEnv();
}
G4VModularPhysicsList*
G4PhysListFactory::GetReferencePhysList(const G4String& name)
{
G4PhysListRegistry* registry = G4PhysListRegistry::Instance();
G4int oldRegVerbose = registry->GetVerbose();
registry->SetVerbose(verbose);
G4VModularPhysicsList* pl = registry->GetModularPhysicsList(name);
registry->SetVerbose(oldRegVerbose);
return pl;
return G4PhysListRegistry::Instance()->GetModularPhysicsList(name);
}
G4bool G4PhysListFactory::IsReferencePhysList(const G4String& name)
@@ -97,9 +82,29 @@ G4PhysListFactory::AvailablePhysListsEM() const
return G4PhysListRegistry::Instance()->AvailablePhysListsEM();
}
void G4PhysListFactory::PrintAvailablePhysLists() const
void G4PhysListFactory::PrintAvailablePhysLists() const
{
G4PhysListRegistry::Instance()->PrintAvailablePhysLists();
}
void G4PhysListFactory::SetVerbose(G4int val)
{
G4PhysListRegistry::Instance()->SetVerbose(val);
}
G4int G4PhysListFactory::GetVerbose() const
{
return G4PhysListRegistry::Instance()->GetVerbose();
}
void G4PhysListFactory::SetUnknownFatal(G4int val)
{
G4PhysListRegistry::Instance()->SetUnknownFatal(val);
}
G4int G4PhysListFactory::GetUnknownFatal() const
{
return G4PhysListRegistry::Instance()->GetUnknownFatal();
}
} // end-of-space 'g4alt'
@@ -30,13 +30,13 @@
//
// GEANT4 Class file
//
//
// File name: G4PhysListRegistry
//
// Author R. Hatcher 2014-10-15
//
// Modifications: based on G4PhysicsConstructorRegistry
//
//#define G4VERBOSE 1
#include "G4ios.hh"
#include <iomanip>
@@ -65,17 +65,32 @@ G4PhysListRegistry* G4PhysListRegistry::Instance()
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
theInstance->AddPhysicsExtension("GS","G4EmStandardPhysicsGS");
theInstance->AddPhysicsExtension("_GS","G4EmStandardPhysicsGS");
return theInstance;
}
G4PhysListRegistry::G4PhysListRegistry() : verbose(1), unknownFatal(0)
{}
G4PhysListRegistry::G4PhysListRegistry()
: verbose(1)
, unknownFatal(0)
, systemDefault("FTFP_BERT")
{
SetUserDefaultPhysList();
}
G4PhysListRegistry::~G4PhysListRegistry()
{
}
void G4PhysListRegistry::SetUserDefaultPhysList(const G4String& name)
{
if ( name == "" ) userDefault = systemDefault;
else userDefault = name;
}
void G4PhysListRegistry::AddFactory(G4String name, G4VBasePhysListStamper* factory)
{
factories[name] = factory;
@@ -95,14 +110,28 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
G4String plBase = "";
std::vector<G4String> physExt;
std::vector<G4int> physReplace;
G4bool allKnown = DeconstructPhysListName(name,plBase,physExt,physReplace,1);
G4bool allKnown =
DeconstructPhysListName(name,plBase,physExt,physReplace,verbose);
size_t npc = physExt.size();
if ( verbose > 0 ) {
G4cout << "G4PhysListRegistry::GetModularPhysicsList <"
<< name << ">"
<< ", as \"" << plBase << "\" with extensions \"";
for ( size_t ipc = 0; ipc < npc; ++ipc )
G4cout << ((physReplace[ipc]>0)?"_":"+") << physExt[ipc];
G4cout << "\"" << G4endl;
}
if ( ! allKnown ) {
// couldn't match what the user wanted ...
// couldn't match what the user wanted ...
G4cout << "### G4PhysListRegistry WARNING: " << name
<< " is not known" << G4endl << G4endl;
if ( ! unknownFatal ) return 0;
G4ExceptionDescription ED;
ED << "The factory for the physicslist ["<< name << "] does not exist!" << G4endl;
ED << "The factory for the physicslist ["<< name << "] does not exist!"
<< G4endl;
if ( plBase == "" ) {
ED << "Could determine no sensible base physics list" << G4endl;
} else {
@@ -112,29 +141,67 @@ G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
}
ED << "]" << G4endl;
}
G4Exception("G4PhysListRegistry::GetModularPhysicsList", "PhysicsList001", FatalException, ED);
G4Exception("G4PhysListRegistry::GetModularPhysicsList",
"PhysicsList001", FatalException, ED);
return 0;
}
// if we want this method "const" then the next line becomes more complex
// because there is no const version of [] (which adds an entry if the key doesn't exist)
// because there is no const version of [] (which adds an entry if the
// key doesn't exist)
G4VModularPhysicsList* pl = factories[plBase]->Instantiate(verbose);
G4PhysicsConstructorRegistry* pcRegistry = G4PhysicsConstructorRegistry::Instance();
size_t npc = physExt.size();
G4PhysicsConstructorRegistry* pcRegistry =
G4PhysicsConstructorRegistry::Instance();
G4int ver = pl->GetVerboseLevel();
pl->SetVerboseLevel(0);
for ( 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
// got back a list of short names, need to use the map to get the
// full physics constructor name
G4String extName = physExt[ipc];
G4String pcname = physicsExtensions[extName];
// this doesn't have a verbose option ... it should
// but G4PhysicsConstructorFactory doesn't support it
G4VPhysicsConstructor* pc = pcRegistry->GetPhysicsConstructor(pcname);
G4String reporreg = "";
if ( physReplace[ipc] > 0 ) {
pl->ReplacePhysics(pc);
reporreg = "ReplacePhysics ";
} else {
pl->RegisterPhysics(pc);
reporreg = "RegisterPhysics";
}
if ( verbose > 0 ) G4cout << "<<< " << reporreg << " with " << pcname
<< " \"" << extName << "\"" << G4endl;
}
pl->SetVerboseLevel(ver);
G4cout << "<<< Reference Physics List " << name << " is built" << G4endl;
G4cout << G4endl; // old factory has this
return pl;
}
G4VModularPhysicsList*
G4PhysListRegistry::GetModularPhysicsListFromEnv()
{
//
// instantiate PhysList by environment variable "PHYSLIST"
// if not set use default
G4String name = "";
char* path = getenv("PHYSLIST");
if (path) {
name = G4String(path);
} else {
name = userDefault;
G4cout << "### G4PhysListRegistry WARNING: "
<< " environment variable PHYSLIST is not defined"
<< G4endl
<< " Default Physics Lists " << name
<< " is instantiated"
<< G4endl;
}
return GetModularPhysicsList(name);
}
G4bool G4PhysListRegistry::IsReferencePhysList(G4String name) const
{
G4String plBase = "";
@@ -145,10 +212,10 @@ G4bool G4PhysListRegistry::IsReferencePhysList(G4String name) const
}
G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
G4String& plBase,
std::vector<G4String>& physExt,
std::vector<G4int>& replace,
G4int verb) const
G4String& plBase,
std::vector<G4String>& physExt,
std::vector<G4int>& replace,
G4int verb) const
{
// Take apart a name given to us by the user
// this name might be a base PhysList + unknown number of extensions
@@ -168,6 +235,9 @@ G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
const std::vector<G4String>& availBases = AvailablePhysLists();
const std::vector<G4String>& availExtras = AvailablePhysicsExtensions();
G4PhysicsConstructorRegistry* physConstRegistry =
G4PhysicsConstructorRegistry::Instance();
// find the longest base list that is contained in the user supplied name
// and starts at the beginning
size_t nb = availBases.size();
@@ -236,6 +306,21 @@ G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
}
#endif
if ( extraKnown ) {
// physics mapping name is known, but is it actually linked to physics?
//const issue// G4String pcname = physicsExtensions[extraName];
std::map<G4String,G4String>::const_iterator itr =
physicsExtensions.find(extraName);
G4String pcname = "";
if ( itr != physicsExtensions.end() ) pcname = itr->second;
bool realknown = physConstRegistry->IsKnownPhysicsConstructor(pcname);
#ifdef G4VERBOSE
if ( verb > 2 ) {
G4cout << " extraName \"" << extraName << "\" maps to physics ctor \""
<< pcname << "\" which is itself realknown " << realknown
<< G4endl;
}
#endif
if ( ! realknown ) allKnown = false;
physExt.push_back(extraName);
replace.push_back(replaceExtra);
// and remove it so we can look for the next bit
@@ -273,7 +358,8 @@ const std::vector<G4String>& G4PhysListRegistry::AvailablePhysicsExtensions() co
const std::vector<G4String>& G4PhysListRegistry::AvailablePhysListsEM() const
{
// in principle this method could weed out all the extensions that aren't
// EM replacements ... but for now just use it as a synonym for AvailablePhysicsExtensions()
// EM replacements ... but for now just use it as a synonym for
// AvailablePhysicsExtensions()
return AvailablePhysicsExtensions();
}
@@ -292,24 +378,20 @@ void G4PhysListRegistry::PrintAvailablePhysLists() const
}
G4PhysicsConstructorRegistry* physConstRegistry = G4PhysicsConstructorRegistry::Instance();
///std::vector<G4String> physConstNames = physConstRegistry->AvailablePhysicsConstructors();
std::map<G4String,G4String>::const_iterator itr;
G4cout << "Replacement mappings in G4PhysListRegistry are:"
<< G4endl;
for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
//bool known = ( find(physConstNames.begin(),physConstName.end(),itr->second) != physConstNames.end() );
bool known = physConstRegistry->IsKnownPhysicsConstructor(itr->second);
G4cout << " " << std::setw(10) << itr->first << " => "
<< std::setw(30) << itr->second << " "
<< ( (known)?"":"[unregistered physics]")
<< G4endl;
}
G4cout << "Use these mapping to extend physics list; append with _EXT or +EXT" << G4endl
<< " to use ReplacePhysics() (\"_\") or RegisterPhysics() (\"+\")."
<< G4endl;
}
// need something that will trigger compilation
//#include "RegisterPhysLists.icc"
@@ -88,47 +88,37 @@ G4_DECLARE_PHYSLIST_FACTORY(QGSP_INCLXX_HP);
#include "Shielding.hh"
G4_DECLARE_PHYSLIST_FACTORY(Shielding);
/***********************************************************************
// rhatcher 2014-11-07
// investigating why this is problematic for mac/clang & linux/icc
// so for now don't support ShieldingLEND and ShieldingM
// some extra hoops because the physlist factory expects to be able
// to construct a list using no args (or just a verbosity)
// to construct a list using just a verbosity argument
// but
// "ShieldingLEND" is Shielding(verbose,"LEND");
// "ShieldingM" is Shielding(verbose,"HP","M");
template<class T>
class TShieldingLEND : public Shielding
class ShieldingLEND : public Shielding
{
public:
explicit TShieldingLEND(G4int verbose = 1) : TShielding(verbose,"LEND") { ; }
virtual ~TShieldingLEND() { ; }
explicit ShieldingLEND(G4int verbose = 1) : Shielding(verbose,"LEND","") { ; }
virtual ~ShieldingLEND() { ; }
};
typedef TShieldingLEND<G4VModularPhysicsList> ShieldingLEND;
G4_DECLARE_PHYSLIST_FACTORY(ShieldingLEND);
template<class T>
class TShieldingM : public Shielding
class ShieldingM : public Shielding
{
public:
explicit TShieldingM(G4int verbose = 1) : TShielding(verbose,"HP","M") { ; }
virtual ~TShieldingM() { ; }
explicit ShieldingM(G4int verbose = 1) : Shielding(verbose,"HP","M") { ; }
virtual ~ShieldingM() { ; }
};
typedef TShieldingM<G4VModularPhysicsList> ShieldingM;
G4_DECLARE_PHYSLIST_FACTORY(ShieldingM);
***********************************************************************/
#include "NuBeam.hh"
G4_DECLARE_PHYSLIST_FACTORY(NuBeam);
/***********************************************************************
// rhatcher 2014-11-07
// investigating why this is problematic for mac/clang ( & linux/icc ? )
// for __clang__ this this needs intercoms/include/G4AnyMethod.hh
// to not attempt to defined remove_reference templates, but use std C++11
#include "G4GenericPhysicsList.hh"
G4_DECLARE_PHYSLIST_FACTORY(G4GenericPhysicsList);
***********************************************************************/
#include "QGSP_BIC_AllHP.hh"
G4_DECLARE_PHYSLIST_FACTORY(QGSP_BIC_AllHP);
//