53#define REGREF PhysListReg
54#include "G4RegisterPhysicsConstructors.icc"
57#include "G4RegisterPhysLists.icc"
66 if ( 0 == theInstance) {
70 theInstance = &manager;
92G4PhysListRegistry::G4PhysListRegistry()
95 , systemDefault(
"FTFP_BERT")
106 if ( name ==
"" ) userDefault = systemDefault;
107 else userDefault = name;
112 factories[name] = factory;
118 physicsExtensions[name] = procname;
127 std::vector<G4String> physExt;
128 std::vector<G4int> physReplace;
132 size_t npc = physExt.size();
134 G4cout <<
"G4PhysListRegistry::GetModularPhysicsList <"
136 <<
", as \"" << plBase <<
"\" with extensions \"";
137 for (
size_t ipc = 0; ipc < npc; ++ipc )
144 G4cout <<
"### G4PhysListRegistry WARNING: " << name
146 if ( ! unknownFatal )
return 0;
149 ED <<
"The factory for the physicslist ["<< name <<
"] does not exist!"
151 if ( plBase ==
"" ) {
152 ED <<
"Could determine no sensible base physics list" <<
G4endl;
154 ED <<
"One or more of the extensions does not exist [ ";
155 for (
size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
156 ED << physExt[ipc] <<
" ";
160 G4Exception(
"G4PhysListRegistry::GetModularPhysicsList",
173 for (
size_t ipc = 0; ipc < npc; ++ipc ) {
178 ((physReplace[ipc]&
isCtorName)) ? extName : physicsExtensions[extName];
185 reporreg =
"ReplacePhysics ";
188 reporreg =
"RegisterPhysics";
190 if ( verbose > 0 )
G4cout <<
"<<< " << reporreg <<
" with " << pcname
191 <<
" \"" << extName <<
"\"" <<
G4endl;
194 G4cout <<
"<<< Reference Physics List " << name <<
" is built" <<
G4endl;
207 char* path = std::getenv(
"PHYSLIST");
212 G4cout <<
"### G4PhysListRegistry WARNING: "
213 <<
" environment variable PHYSLIST is not defined"
215 <<
" Default Physics Lists " << name
216 <<
" is instantiated"
225 std::vector<G4String> physExt;
226 std::vector<G4int> physReplace;
233 std::vector<G4String>& physExt,
234 std::vector<G4int>& replace,
248 bool allKnown =
false;
258 const std::vector<G4String>& availPhysCtors =
266 G4cout <<
" " << name <<
", base known=" << ((allKnown)?
"true":
"false")
267 <<
" chosen plBase \"" << plBase <<
"\"" <<
G4endl;
275 workingName.erase(0,plBase.size());
280 while ( ! workingName.empty() ) {
281 char c = workingName.
data()[0];
282 if (
'_' == c ||
'+' == c ) workingName.erase(0,1);
285 G4bool extraKnown =
false;
287 extraKnown =
FindLongestMatch(workingName,
"extNames",availExtras,extraName);
291 std::map<G4String,G4String>::const_iterator itr =
292 physicsExtensions.find(extraName);
294 if ( itr != physicsExtensions.end() ) pcname = itr->second;
296 if ( ! realknown ) allKnown =
false;
299 G4cout <<
" extraName \"" << extraName <<
"\" maps to physics ctor \""
300 << pcname <<
"\" which is itself realknown " << realknown
312 G4cout <<
" physextra " << name <<
" [" << workingName <<
"]"
313 <<
", extra known " << extraKnown
314 <<
" chosen extra \"" << extraName <<
"\""
315 <<
" replace " << replaceExtra <<
G4endl;
319 physExt.push_back(extraName);
320 replace.push_back(replaceExtra);
322 workingName.erase(0,extraName.size());
327 G4cout <<
" workingName \"" << workingName <<
"\""
328 <<
" couldn't be found in the extensions list"
343 const std::vector<G4String>& validNames,
350 size_t n = validNames.size();
351 for (
size_t i=0; i<n; ++i) {
352 const G4String& testName = validNames[i];
353 size_t ipos = workingName.find(testName);
355 if ( testName.size() > bestMatch.size() ) {
356 bestMatch = testName;
359 G4cout <<
" " << searchName <<
" current best guess: "
364 G4cout <<
" " << searchName <<
" match but shorter: "
370 G4cout <<
" " << searchName <<
" reject: " << testName <<
G4endl;
380 availBasePhysLists.clear();
381 std::map<G4String,G4VBasePhysListStamper*>::const_iterator itr;
382 for ( itr = factories.begin(); itr != factories.end(); ++itr ) {
383 availBasePhysLists.push_back(itr->first);
386 return availBasePhysLists;
391 availExtensions.clear();
392 std::map<G4String,G4String>::const_iterator itr;
393 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
394 availExtensions.push_back(itr->first);
397 return availExtensions;
411 G4cout <<
"Base G4VModularPhysicsLists in G4PhysListRegistry are:"
413 if ( avail.empty() )
G4cout <<
"... no registered lists" <<
G4endl;
415 size_t n = avail.size();
416 for (
size_t i=0; i<n; ++i ) {
417 G4cout <<
" [" << std::setw(3) << i <<
"] "
418 <<
" \"" << avail[i] <<
"\"" <<
G4endl;
424 std::map<G4String,G4String>::const_iterator itr;
425 G4cout <<
"Replacement mappings in G4PhysListRegistry are:"
427 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
430 G4cout <<
" " << std::setw(10) << itr->first <<
" => "
431 << std::setw(30) << itr->second <<
" "
432 << ( (known)?
"":
"[unregistered physics]")
435 G4cout <<
"Use these mapping to extend physics list; append with _EXT or +EXT" <<
G4endl
436 <<
" to use ReplacePhysics() (\"_\") or RegisterPhysics() (\"+\")."
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void PrintAvailablePhysLists() const
G4VModularPhysicsList * GetModularPhysicsListFromEnv()
const std::vector< G4String > & AvailablePhysLists() const
void AddFactory(G4String name, G4VBasePhysListStamper *)
void SetUserDefaultPhysList(const G4String &name="")
const std::vector< G4String > & AvailablePhysListsEM() const
const std::vector< G4String > & AvailablePhysicsExtensions() const
static G4PhysListRegistry * Instance()
G4bool DeconstructPhysListName(const G4String &name, G4String &plBase, std::vector< G4String > &physExt, std::vector< G4int > &replace, G4int verbose=0) const
G4bool IsReferencePhysList(G4String nam) const
G4VModularPhysicsList * GetModularPhysicsList(const G4String &name)
void AddPhysicsExtension(G4String name, G4String procname)
G4bool FindLongestMatch(const G4String &workName, const G4String &searchName, const std::vector< G4String > &validNames, G4String &bestMatch, G4int verbose=0) const
G4VPhysicsConstructor * GetPhysicsConstructor(const G4String &name)
static G4PhysicsConstructorRegistry * Instance()
std::vector< G4String > AvailablePhysicsConstructors() const
G4bool IsKnownPhysicsConstructor(const G4String &name)
const char * data() const
void SetVerboseLevel(G4int value)
G4int GetVerboseLevel() const
void RegisterPhysics(G4VPhysicsConstructor *)
void ReplacePhysics(G4VPhysicsConstructor *)