Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PhysListRegistry Class Reference

#include <G4PhysListRegistry.hh>

Public Member Functions

 ~G4PhysListRegistry ()
 
void AddFactory (G4String name, G4VBasePhysListStamper *)
 
void AddPhysicsExtension (G4String name, G4String procname)
 
G4VModularPhysicsListGetModularPhysicsList (const G4String &name)
 
G4VModularPhysicsListGetModularPhysicsListFromEnv ()
 
G4bool IsReferencePhysList (G4String nam) const
 
const std::vector< G4String > & AvailablePhysLists () const
 
const std::vector< G4String > & AvailablePhysicsExtensions () const
 
const std::vector< G4String > & AvailablePhysListsEM () const
 
void PrintAvailablePhysLists () const
 
G4bool DeconstructPhysListName (const G4String &name, G4String &plBase, std::vector< G4String > &physExt, std::vector< G4int > &replace, G4int verbose=0) const
 
void SetVerbose (G4int val)
 
G4int GetVerbose () const
 
void SetUnknownFatal (G4int val)
 
G4int GetUnknownFatal () const
 
void SetUserDefaultPhysList (const G4String &name="")
 
G4String GetUserDefaultPhysList () const
 
G4String GetSystemDefaultPhysList () const
 

Static Public Member Functions

static G4PhysListRegistryInstance ()
 

Detailed Description

Definition at line 57 of file G4PhysListRegistry.hh.

Constructor & Destructor Documentation

G4PhysListRegistry::~G4PhysListRegistry ( )

Definition at line 87 of file G4PhysListRegistry.cc.

88 {
89 }

Member Function Documentation

void G4PhysListRegistry::AddFactory ( G4String  name,
G4VBasePhysListStamper factory 
)

Definition at line 97 of file G4PhysListRegistry.cc.

98 {
99  factories[name] = factory;
100 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

void G4PhysListRegistry::AddPhysicsExtension ( G4String  name,
G4String  procname 
)

Definition at line 102 of file G4PhysListRegistry.cc.

103 {
104  // a mapping from short extension names to actual physics process constructors
105  physicsExtensions[name] = procname;
106 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

const std::vector< G4String > & G4PhysListRegistry::AvailablePhysicsExtensions ( ) const

Definition at line 367 of file G4PhysListRegistry.cc.

368 {
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);
373  }
374 
375  return availExtensions;
376 }

Here is the caller graph for this function:

const std::vector< G4String > & G4PhysListRegistry::AvailablePhysLists ( ) const

Definition at line 356 of file G4PhysListRegistry.cc.

357 {
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);
362  }
363 
364  return availBasePhysLists;
365 }

Here is the caller graph for this function:

const std::vector< G4String > & G4PhysListRegistry::AvailablePhysListsEM ( ) const

Definition at line 378 of file G4PhysListRegistry.cc.

379 {
380  // in principle this method could weed out all the extensions that aren't
381  // EM replacements ... but for now just use it as a synonym for
382  // AvailablePhysicsExtensions()
384 }
const std::vector< G4String > & AvailablePhysicsExtensions() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4PhysListRegistry::DeconstructPhysListName ( const G4String name,
G4String plBase,
std::vector< G4String > &  physExt,
std::vector< G4int > &  replace,
G4int  verbose = 0 
) const

Definition at line 217 of file G4PhysListRegistry.cc.

222 {
223  // Take apart a name given to us by the user
224  // this name might be a base PhysList + unknown number of extensions
225  // Extensions preceeded with a "_" should use
226  // ReplacePhysics()
227  // those proceeded with a "+" should use
228  // RegisterPhysics()
229  // the former is in line with previous behaviour, while the second allows
230  // additional flexibility
231  plBase = "";
232  physExt.clear();
233  replace.clear();
234  bool allKnown = false;
235 
236  G4String workingName = name;
237 
238  const std::vector<G4String>& availBases = AvailablePhysLists();
239  const std::vector<G4String>& availExtras = AvailablePhysicsExtensions();
240 
241  G4PhysicsConstructorRegistry* physConstRegistry =
243 
244  // find the longest base list that is contained in the user supplied name
245  // and starts at the beginning
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);
250  if ( ipos == 0 ) {
251  if ( testBase.size() > plBase.size() ) {
252  plBase = testBase;
253  allKnown = true;
254  if ( verb > 3 ) { G4cout << " physlist current best guess: " << testBase << G4endl; }
255  } else {
256  if ( verb > 3 ) { G4cout << " physlist match but shorter: " << testBase << G4endl; }
257  }
258  } else {
259  if ( verb > 3 ) { G4cout << " physlist reject: " << testBase << G4endl; }
260  }
261  }
262  if ( verb > 2 ) {
263  G4cout << " physlist " << name << ", base known " << allKnown
264  << " chosen plBase \"" << plBase << "\"" << G4endl;
265  }
266  if ( ! allKnown ) {
267  // didn't find any matching base physics list
268  // no point of going on to the extensions
269  return allKnown;
270  }
271  // remove base name for working name
272  workingName.erase(0,plBase.size());
273 
274  // now start trying to match up extensions
275  // each should be preceeded by at "_" (replace) or "+" (register)
276  // but don't freak if it isn't, just assume "_"
277  size_t ne = availExtras.size();
278  while ( ! workingName.empty() ) {
279  char c = workingName.data()[0]; // leading character
280  if ( '_' == c || '+' == c ) workingName.erase(0,1); // and remove it
281  G4int replaceExtra = ( c != '+' );
282  G4String extraName = "";
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);
287  if ( ipos == 0 ) {
288  if ( testExtra.size() > extraName.size() ) {
289  extraName = testExtra;
290  extraKnown = true;
291 #ifdef G4VERBOSE
292  if ( verb > 3 ) {
293  G4cout << " physextra current best guess: "
294  << testExtra << G4endl;
295  }
296  } else {
297  if ( verb > 3 ) {
298  G4cout << " physextra match but shorter: "
299  << testExtra << G4endl;
300  }
301 #endif
302  }
303  } else {
304 #ifdef G4VERBOSE
305  if ( verb > 3 ) {
306  G4cout << " physextra reject: " << testExtra << G4endl;
307  }
308 #endif
309  }
310  }
311 #ifdef G4VERBOSE
312  if ( verb > 2 ) {
313  G4cout << " physextra " << name << " [" << workingName << "]"
314  <<", extra known " << extraKnown
315  << " chosen extra \"" << extraName << "\""
316  << " replace " << replaceExtra << G4endl;
317  }
318 #endif
319  if ( extraKnown ) {
320  // physics mapping name is known, but is it actually linked to physics?
321  //const issue// G4String pcname = physicsExtensions[extraName];
322  std::map<G4String,G4String>::const_iterator itr =
323  physicsExtensions.find(extraName);
324  G4String pcname = "";
325  if ( itr != physicsExtensions.end() ) pcname = itr->second;
326  bool realknown = physConstRegistry->IsKnownPhysicsConstructor(pcname);
327 #ifdef G4VERBOSE
328  if ( verb > 2 ) {
329  G4cout << " extraName \"" << extraName << "\" maps to physics ctor \""
330  << pcname << "\" which is itself realknown " << realknown
331  << G4endl;
332  }
333 #endif
334  if ( ! realknown ) allKnown = false;
335  physExt.push_back(extraName);
336  replace.push_back(replaceExtra);
337  // and remove it so we can look for the next bit
338  workingName.erase(0,extraName.size());
339  } else {
340 #ifdef G4VERBOSE
341  if ( verb > 2 ) {
342  G4cout << " workingName \"" << workingName << "\""
343  << " couldn't be found in the extensions list"
344  << G4endl;
345  }
346 #endif
347  allKnown = false;
348  // found a pattern that we can't map
349  return allKnown;
350  }
351  } // workingName not empty
352 
353  return allKnown;
354 }
const XML_Char * name
Definition: expat.h:151
G4bool IsKnownPhysicsConstructor(const G4String &name)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
const char * data() const
static G4PhysicsConstructorRegistry * Instance()
const std::vector< G4String > & AvailablePhysicsExtensions() const
#define G4endl
Definition: G4ios.hh:61
tuple c
Definition: test.py:13
const std::vector< G4String > & AvailablePhysLists() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4VModularPhysicsList * G4PhysListRegistry::GetModularPhysicsList ( const G4String name)

Definition at line 109 of file G4PhysListRegistry.cc.

110 {
111  //
112  //
113  G4String plBase = "";
114  std::vector<G4String> physExt;
115  std::vector<G4int> physReplace;
116  G4bool allKnown =
117  DeconstructPhysListName(name,plBase,physExt,physReplace,verbose);
118 
119  size_t npc = physExt.size();
120  if ( verbose > 0 ) {
121  G4cout << "G4PhysListRegistry::GetModularPhysicsList <"
122  << name << ">"
123  << ", as \"" << plBase << "\" with extensions \"";
124  for ( size_t ipc = 0; ipc < npc; ++ipc )
125  G4cout << ((physReplace[ipc]>0)?"_":"+") << physExt[ipc];
126  G4cout << "\"" << G4endl;
127  }
128 
129  if ( ! allKnown ) {
130  // couldn't match what the user wanted ...
131  G4cout << "### G4PhysListRegistry WARNING: " << name
132  << " is not known" << G4endl << G4endl;
133  if ( ! unknownFatal ) return 0;
134 
136  ED << "The factory for the physicslist ["<< name << "] does not exist!"
137  << G4endl;
138  if ( plBase == "" ) {
139  ED << "Could determine no sensible base physics list" << G4endl;
140  } else {
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] << " ";
144  }
145  ED << "]" << G4endl;
146  }
147  G4Exception("G4PhysListRegistry::GetModularPhysicsList",
148  "PhysicsList002", FatalException, ED);
149  return 0;
150  }
151 
152  // if we want this method "const" then the next line becomes more complex
153  // because there is no const version of [] (which adds an entry if the
154  // key doesn't exist)
155  G4VModularPhysicsList* pl = factories[plBase]->Instantiate(verbose);
156  G4PhysicsConstructorRegistry* pcRegistry =
158  G4int ver = pl->GetVerboseLevel();
159  pl->SetVerboseLevel(0);
160  for ( size_t ipc = 0; ipc < npc; ++ipc ) {
161  // got back a list of short names, need to use the map to get the
162  // full physics constructor name
163  G4String extName = physExt[ipc];
164  G4String pcname = physicsExtensions[extName];
165  // this doesn't have a verbose option ... it should
166  // but G4PhysicsConstructorFactory doesn't support it
167  G4VPhysicsConstructor* pctor = pcRegistry->GetPhysicsConstructor(pcname);
168  G4String reporreg = "";
169  if ( physReplace[ipc] > 0 ) {
170  pl->ReplacePhysics(pctor);
171  reporreg = "ReplacePhysics ";
172  } else {
173  pl->RegisterPhysics(pctor);
174  reporreg = "RegisterPhysics";
175  }
176  if ( verbose > 0 ) G4cout << "<<< " << reporreg << " with " << pcname
177  << " \"" << extName << "\"" << G4endl;
178  }
179  pl->SetVerboseLevel(ver);
180  G4cout << "<<< Reference Physics List " << name << " is built" << G4endl;
181  G4cout << G4endl; // old factory has this
182 
183  return pl;
184 }
void RegisterPhysics(G4VPhysicsConstructor *)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int G4int
Definition: G4Types.hh:78
tuple pl
Definition: readPY.py:5
G4GLOB_DLL std::ostream G4cout
G4VPhysicsConstructor * GetPhysicsConstructor(const G4String &name)
bool G4bool
Definition: G4Types.hh:79
void SetVerboseLevel(G4int value)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void ReplacePhysics(G4VPhysicsConstructor *)
static G4PhysicsConstructorRegistry * Instance()
G4bool DeconstructPhysListName(const G4String &name, G4String &plBase, std::vector< G4String > &physExt, std::vector< G4int > &replace, G4int verbose=0) const
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4VModularPhysicsList * G4PhysListRegistry::GetModularPhysicsListFromEnv ( )

Definition at line 187 of file G4PhysListRegistry.cc.

188 {
189  //
190  // instantiate PhysList by environment variable "PHYSLIST"
191  // if not set use default
192  G4String name = "";
193  char* path = getenv("PHYSLIST");
194  if (path) {
195  name = G4String(path);
196  } else {
197  name = userDefault;
198  G4cout << "### G4PhysListRegistry WARNING: "
199  << " environment variable PHYSLIST is not defined"
200  << G4endl
201  << " Default Physics Lists " << name
202  << " is instantiated"
203  << G4endl;
204  }
205  return GetModularPhysicsList(name);
206 }
const XML_Char * name
Definition: expat.h:151
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4VModularPhysicsList * GetModularPhysicsList(const G4String &name)

Here is the call graph for this function:

Here is the caller graph for this function:

G4String G4PhysListRegistry::GetSystemDefaultPhysList ( ) const
inline

Definition at line 98 of file G4PhysListRegistry.hh.

98 { return systemDefault; }
G4int G4PhysListRegistry::GetUnknownFatal ( ) const
inline

Definition at line 91 of file G4PhysListRegistry.hh.

91 { return unknownFatal; }

Here is the caller graph for this function:

G4String G4PhysListRegistry::GetUserDefaultPhysList ( ) const
inline

Definition at line 94 of file G4PhysListRegistry.hh.

94 { return userDefault; }
G4int G4PhysListRegistry::GetVerbose ( ) const
inline

Definition at line 88 of file G4PhysListRegistry.hh.

88 { return verbose; }

Here is the caller graph for this function:

G4PhysListRegistry * G4PhysListRegistry::Instance ( void  )
static

Definition at line 55 of file G4PhysListRegistry.cc.

56 {
57  if ( 0 == theInstance) {
58  static G4ThreadLocal G4PhysListRegistry *manager_G4MT_TLS_ = 0;
59  if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4PhysListRegistry;
60  G4PhysListRegistry &manager = *manager_G4MT_TLS_;
61  theInstance = &manager;
62  }
63 
64  // common EM overrides
65  theInstance->AddPhysicsExtension("EMV","G4EmStandardPhysics_option1");
66  theInstance->AddPhysicsExtension("EMX","G4EmStandardPhysics_option2");
67  theInstance->AddPhysicsExtension("EMY","G4EmStandardPhysics_option3");
68  theInstance->AddPhysicsExtension("EMZ","G4EmStandardPhysics_option4");
69  theInstance->AddPhysicsExtension("LIV","G4EmLivermorePhysics");
70  theInstance->AddPhysicsExtension("PEN","G4EmPenelopePhysics");
71  // the GS EM extension originally required double underscores
72  // support either one or two as __GS is confusing to users
73  theInstance->AddPhysicsExtension("GS","G4EmStandardPhysicsGS");
74  theInstance->AddPhysicsExtension("_GS","G4EmStandardPhysicsGS");
75 
76  return theInstance;
77 }
#define G4ThreadLocal
Definition: tls.hh:89
void AddPhysicsExtension(G4String name, G4String procname)

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4PhysListRegistry::IsReferencePhysList ( G4String  nam) const

Definition at line 208 of file G4PhysListRegistry.cc.

209 {
210  G4String plBase = "";
211  std::vector<G4String> physExt;
212  std::vector<G4int> physReplace;
213  G4bool allKnown = DeconstructPhysListName(name,plBase,physExt,physReplace,1);
214  return allKnown;
215 }
const XML_Char * name
Definition: expat.h:151
bool G4bool
Definition: G4Types.hh:79
G4bool DeconstructPhysListName(const G4String &name, G4String &plBase, std::vector< G4String > &physExt, std::vector< G4int > &replace, G4int verbose=0) const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PhysListRegistry::PrintAvailablePhysLists ( ) const

Definition at line 386 of file G4PhysListRegistry.cc.

387 {
388  std::vector<G4String> avail = AvailablePhysLists();
389  G4cout << "Base G4VModularPhysicsLists in G4PhysListRegistry are:"
390  << G4endl;
391  if ( avail.empty() ) G4cout << "... no registered lists" << G4endl;
392  else {
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;
397  }
398  }
399 
401 
402  std::map<G4String,G4String>::const_iterator itr;
403  G4cout << "Replacement mappings in G4PhysListRegistry are:"
404  << G4endl;
405  for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
406  bool known = physConstRegistry->IsKnownPhysicsConstructor(itr->second);
407 
408  G4cout << " " << std::setw(10) << itr->first << " => "
409  << std::setw(30) << itr->second << " "
410  << ( (known)?"":"[unregistered physics]")
411  << G4endl;
412  }
413  G4cout << "Use these mapping to extend physics list; append with _EXT or +EXT" << G4endl
414  << " to use ReplacePhysics() (\"_\") or RegisterPhysics() (\"+\")."
415  << G4endl;
416 }
G4bool IsKnownPhysicsConstructor(const G4String &name)
G4GLOB_DLL std::ostream G4cout
const G4int n
static G4PhysicsConstructorRegistry * Instance()
#define G4endl
Definition: G4ios.hh:61
const std::vector< G4String > & AvailablePhysLists() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PhysListRegistry::SetUnknownFatal ( G4int  val)
inline

Definition at line 90 of file G4PhysListRegistry.hh.

90 { unknownFatal = val; }

Here is the caller graph for this function:

void G4PhysListRegistry::SetUserDefaultPhysList ( const G4String name = "")

Definition at line 91 of file G4PhysListRegistry.cc.

92 {
93  if ( name == "" ) userDefault = systemDefault;
94  else userDefault = name;
95 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

void G4PhysListRegistry::SetVerbose ( G4int  val)
inline

Definition at line 87 of file G4PhysListRegistry.hh.

87 { verbose = val; }

Here is the caller graph for this function:


The documentation for this class was generated from the following files: