51 #include "G4RegisterPhysLists.icc"
57 if ( 0 == theInstance) {
61 theInstance = &manager;
79 G4PhysListRegistry::G4PhysListRegistry()
82 , systemDefault(
"FTFP_BERT")
93 if ( name ==
"" ) userDefault = systemDefault;
94 else userDefault =
name;
99 factories[
name] = factory;
105 physicsExtensions[
name] = procname;
114 std::vector<G4String> physExt;
115 std::vector<G4int> physReplace;
119 size_t npc = physExt.size();
121 G4cout <<
"G4PhysListRegistry::GetModularPhysicsList <"
123 <<
", as \"" << plBase <<
"\" with extensions \"";
124 for (
size_t ipc = 0; ipc < npc; ++ipc )
125 G4cout << ((physReplace[ipc]>0)?
"_":
"+") << physExt[ipc];
131 G4cout <<
"### G4PhysListRegistry WARNING: " << name
133 if ( ! unknownFatal )
return 0;
136 ED <<
"The factory for the physicslist ["<< name <<
"] does not exist!"
138 if ( plBase ==
"" ) {
139 ED <<
"Could determine no sensible base physics list" <<
G4endl;
141 ED <<
"One or more of the extensions does not exist [ ";
142 for (
size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
143 ED << physExt[ipc] <<
" ";
147 G4Exception(
"G4PhysListRegistry::GetModularPhysicsList",
160 for (
size_t ipc = 0; ipc < npc; ++ipc ) {
164 G4String pcname = physicsExtensions[extName];
169 if ( physReplace[ipc] > 0 ) {
171 reporreg =
"ReplacePhysics ";
174 reporreg =
"RegisterPhysics";
176 if ( verbose > 0 )
G4cout <<
"<<< " << reporreg <<
" with " << pcname
177 <<
" \"" << extName <<
"\"" <<
G4endl;
180 G4cout <<
"<<< Reference Physics List " << name <<
" is built" <<
G4endl;
193 char* path = getenv(
"PHYSLIST");
198 G4cout <<
"### G4PhysListRegistry WARNING: "
199 <<
" environment variable PHYSLIST is not defined"
201 <<
" Default Physics Lists " << name
202 <<
" is instantiated"
211 std::vector<G4String> physExt;
212 std::vector<G4int> physReplace;
219 std::vector<G4String>& physExt,
220 std::vector<G4int>& replace,
234 bool allKnown =
false;
246 size_t nb = availBases.size();
247 for (
size_t ib=0; ib<nb; ++ib) {
248 const G4String& testBase = availBases[ib];
249 size_t ipos = workingName.find(testBase);
251 if ( testBase.size() > plBase.size() ) {
254 if ( verb > 3 ) {
G4cout <<
" physlist current best guess: " << testBase <<
G4endl; }
256 if ( verb > 3 ) {
G4cout <<
" physlist match but shorter: " << testBase <<
G4endl; }
259 if ( verb > 3 ) {
G4cout <<
" physlist reject: " << testBase <<
G4endl; }
263 G4cout <<
" physlist " << name <<
", base known " << allKnown
264 <<
" chosen plBase \"" << plBase <<
"\"" <<
G4endl;
272 workingName.erase(0,plBase.size());
277 size_t ne = availExtras.size();
278 while ( ! workingName.empty() ) {
279 char c = workingName.
data()[0];
280 if (
'_' == c ||
'+' == c ) workingName.erase(0,1);
281 G4int replaceExtra = ( c !=
'+' );
283 G4bool extraKnown =
false;
284 for (
size_t ie=0; ie<ne; ++ie) {
285 const G4String& testExtra = availExtras[ie];
286 size_t ipos = workingName.find(testExtra);
288 if ( testExtra.size() > extraName.size() ) {
289 extraName = testExtra;
293 G4cout <<
" physextra current best guess: "
298 G4cout <<
" physextra match but shorter: "
313 G4cout <<
" physextra " << name <<
" [" << workingName <<
"]"
314 <<
", extra known " << extraKnown
315 <<
" chosen extra \"" << extraName <<
"\""
316 <<
" replace " << replaceExtra <<
G4endl;
322 std::map<G4String,G4String>::const_iterator itr =
323 physicsExtensions.find(extraName);
325 if ( itr != physicsExtensions.end() ) pcname = itr->second;
329 G4cout <<
" extraName \"" << extraName <<
"\" maps to physics ctor \""
330 << pcname <<
"\" which is itself realknown " << realknown
334 if ( ! realknown ) allKnown =
false;
335 physExt.push_back(extraName);
336 replace.push_back(replaceExtra);
338 workingName.erase(0,extraName.size());
342 G4cout <<
" workingName \"" << workingName <<
"\""
343 <<
" couldn't be found in the extensions list"
358 availBasePhysLists.clear();
359 std::map<G4String,G4VBasePhysListStamper*>::const_iterator itr;
360 for ( itr = factories.begin(); itr != factories.end(); ++itr ) {
361 availBasePhysLists.push_back(itr->first);
364 return availBasePhysLists;
369 availExtensions.clear();
370 std::map<G4String,G4String>::const_iterator itr;
371 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
372 availExtensions.push_back(itr->first);
375 return availExtensions;
389 G4cout <<
"Base G4VModularPhysicsLists in G4PhysListRegistry are:"
391 if ( avail.empty() )
G4cout <<
"... no registered lists" << G4endl;
393 size_t n = avail.size();
394 for (
size_t i=0; i<
n; ++i ) {
395 G4cout <<
" [" << std::setw(3) << i <<
"] "
396 <<
" \"" << avail[i] <<
"\"" <<
G4endl;
402 std::map<G4String,G4String>::const_iterator itr;
403 G4cout <<
"Replacement mappings in G4PhysListRegistry are:"
405 for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
408 G4cout <<
" " << std::setw(10) << itr->first <<
" => "
409 << std::setw(30) << itr->second <<
" "
410 << ( (known)?
"":
"[unregistered physics]")
413 G4cout <<
"Use these mapping to extend physics list; append with _EXT or +EXT" << G4endl
414 <<
" to use ReplacePhysics() (\"_\") or RegisterPhysics() (\"+\")."
void RegisterPhysics(G4VPhysicsConstructor *)
std::ostringstream G4ExceptionDescription
G4bool IsKnownPhysicsConstructor(const G4String &name)
void AddFactory(G4String name, G4VBasePhysListStamper *)
G4int GetVerboseLevel() const
G4GLOB_DLL std::ostream G4cout
G4VPhysicsConstructor * GetPhysicsConstructor(const G4String &name)
G4VModularPhysicsList * GetModularPhysicsListFromEnv()
static G4PhysListRegistry * Instance()
void SetVerboseLevel(G4int value)
void SetUserDefaultPhysList(const G4String &name="")
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const char * data() const
const std::vector< G4String > & AvailablePhysListsEM() const
void ReplacePhysics(G4VPhysicsConstructor *)
static G4PhysicsConstructorRegistry * Instance()
const std::vector< G4String > & AvailablePhysicsExtensions() const
G4bool DeconstructPhysListName(const G4String &name, G4String &plBase, std::vector< G4String > &physExt, std::vector< G4int > &replace, G4int verbose=0) const
void PrintAvailablePhysLists() const
G4bool IsReferencePhysList(G4String nam) const
const std::vector< G4String > & AvailablePhysLists() const
G4VModularPhysicsList * GetModularPhysicsList(const G4String &name)
void AddPhysicsExtension(G4String name, G4String procname)