53#define REGREF PhysListReg
54#include "G4RegisterPhysicsConstructors.icc"
57#include "G4RegisterPhysLists.icc"
66 if ( 0 == theInstance) {
70 theInstance = &manager;
97G4PhysListRegistry::G4PhysListRegistry()
100 , systemDefault(
"FTFP_BERT")
111 if ( name ==
"" ) userDefault = systemDefault;
112 else userDefault = name;
117 factories[name] = factory;
123 physicsExtensions[name] = procname;
132 std::vector<G4String> physExt;
133 std::vector<G4int> physReplace;
137 size_t npc = physExt.size();
139 G4cout <<
"G4PhysListRegistry::GetModularPhysicsList <"
141 <<
", as \"" << plBase <<
"\" with extensions \"";
142 for (
size_t ipc = 0; ipc < npc; ++ipc )
149 G4cout <<
"### G4PhysListRegistry WARNING: " << name
151 if ( ! unknownFatal )
return 0;
154 ED <<
"The factory for the physicslist ["<< name <<
"] does not exist!"
156 if ( plBase ==
"" ) {
157 ED <<
"Could determine no sensible base physics list" <<
G4endl;
159 ED <<
"One or more of the extensions does not exist [ ";
160 for (
size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
161 ED << physExt[ipc] <<
" ";
165 G4Exception(
"G4PhysListRegistry::GetModularPhysicsList",
178 for (
size_t ipc = 0; ipc < npc; ++ipc ) {
183 ((physReplace[ipc]&
isCtorName)) ? extName : physicsExtensions[extName];
190 reporreg =
"ReplacePhysics ";
193 reporreg =
"RegisterPhysics";
195 if ( verbose > 0 )
G4cout <<
"<<< " << reporreg <<
" with " << pcname
196 <<
" \"" << extName <<
"\"" <<
G4endl;
199 G4cout <<
"<<< Reference Physics List " << name <<
" is built" <<
G4endl;
212 char* path = std::getenv(
"PHYSLIST");
217 G4cout <<
"### G4PhysListRegistry WARNING: "
218 <<
" environment variable PHYSLIST is not defined"
220 <<
" Default Physics Lists " << name
221 <<
" is instantiated"
230 std::vector<G4String> physExt;
231 std::vector<G4int> physReplace;
238 std::vector<G4String>& physExt,
239 std::vector<G4int>& replace,
253 bool allKnown =
false;
263 const std::vector<G4String>& availPhysCtors =
271 G4cout <<
" " << name <<
", base known=" << ((allKnown)?
"true":
"false")
272 <<
" chosen plBase \"" << plBase <<
"\"" <<
G4endl;
280 workingName.erase(0,plBase.size());
285 while ( ! workingName.empty() ) {
286 char c = workingName.data()[0];
287 if (
'_' == c ||
'+' == c ) workingName.erase(0,1);
290 G4bool extraKnown =
false;
292 extraKnown =
FindLongestMatch(workingName,
"extNames",availExtras,extraName);
296 std::map<G4String,G4String>::const_iterator itr =
297 physicsExtensions.find(extraName);
299 if ( itr != physicsExtensions.end() ) pcname = itr->second;
301 if ( ! realknown ) allKnown =
false;
304 G4cout <<
" extraName \"" << extraName <<
"\" maps to physics ctor \""
305 << pcname <<
"\" which is itself realknown " << realknown
317 G4cout <<
" physextra " << name <<
" [" << workingName <<
"]"
318 <<
", extra known " << extraKnown
319 <<
" chosen extra \"" << extraName <<
"\""
320 <<
" replace " << replaceExtra <<
G4endl;
324 physExt.push_back(extraName);
325 replace.push_back(replaceExtra);
327 workingName.erase(0,extraName.size());
332 G4cout <<
" workingName \"" << workingName <<
"\""
333 <<
" couldn't be found in the extensions list"
348 const std::vector<G4String>& validNames,
355 size_t n = validNames.size();
356 for (
size_t i=0; i<n; ++i) {
357 const G4String& testName = validNames[i];
358 size_t ipos = workingName.find(testName);
360 if ( testName.size() > bestMatch.size() ) {
361 bestMatch = testName;
364 G4cout <<
" " << searchName <<
" current best guess: "
369 G4cout <<
" " << searchName <<
" match but shorter: "
375 G4cout <<
" " << searchName <<
" reject: " << testName <<
G4endl;
385 availBasePhysLists.clear();
386 std::map<G4String,G4VBasePhysListStamper*>::const_iterator itr;
387 for ( itr = factories.begin(); itr != factories.end(); ++itr ) {
388 availBasePhysLists.push_back(itr->first);
391 return availBasePhysLists;
396 availExtensions.clear();
397 std::map<G4String,G4String>::const_iterator itr;
398 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
399 availExtensions.push_back(itr->first);
402 return availExtensions;
416 G4cout <<
"Base G4VModularPhysicsLists in G4PhysListRegistry are:"
418 if ( avail.empty() )
G4cout <<
"... no registered lists" <<
G4endl;
420 size_t n = avail.size();
421 for (
size_t i=0; i<n; ++i ) {
422 G4cout <<
" [" << std::setw(3) << i <<
"] "
423 <<
" \"" << avail[i] <<
"\"" <<
G4endl;
429 std::map<G4String,G4String>::const_iterator itr;
430 G4cout <<
"Replacement mappings in G4PhysListRegistry are:"
432 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
435 G4cout <<
" " << std::setw(10) << itr->first <<
" => "
436 << std::setw(30) << itr->second <<
" "
437 << ( (known)?
"":
"[unregistered physics]")
440 G4cout <<
"Use these mapping to extend physics list; append with _EXT or +EXT" <<
G4endl
441 <<
" 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)
void SetVerboseLevel(G4int value)
G4int GetVerboseLevel() const
void RegisterPhysics(G4VPhysicsConstructor *)
void ReplacePhysics(G4VPhysicsConstructor *)