All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CustomPhysicsTable.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file CustomPhysicsTable.cxx
3 //
4 /// \author bjpjones@mit.edu
5 ////////////////////////////////////////////////////////////////////////
6 // See header file for full description
7 
8 #include "messagefacility/MessageLogger/MessageLogger.h"
9 
12 
13 namespace larg4 {
14 
16 
17  //-----------------------------------------------------------------
19  {
20  if (!TheCustomPhysicsTable) {
23  }
24  else {
26  }
27  }
28 
29  //-----------------------------------------------------------------
30  std::vector<std::string>
32  {
33  std::vector<std::string> ReturnVector;
34  for (std::map<std::string, CustomPhysicsFactoryBase*>::const_iterator i =
36  i != TheCustomPhysicsTable->theTable.end();
37  i++) {
38  ReturnVector.push_back((*i).first);
39  }
40  return ReturnVector;
41  }
42 
43  //-----------------------------------------------------------------
44  bool
45  CustomPhysicsTable::IsPhysicsAvailable(std::string const& PhysicsName)
46  {
47  if (!TheCustomPhysicsTable->theTable[PhysicsName])
48  return false;
49  else
50  return true;
51  }
52 
53  //-----------------------------------------------------------------
54  G4VPhysicsConstructor*
55  CustomPhysicsTable::GetPhysicsConstructor(std::string const& PhysicsName)
56  {
57  if (IsPhysicsAvailable(PhysicsName)) {
58  return TheCustomPhysicsTable->theTable[PhysicsName]->Build();
59  }
60 
61  return nullptr;
62  }
63 
64  //-----------------------------------------------------------------
65  void
67  {
68 
69  if (IsPhysicsAvailable(Factory->GetName()))
70  mf::LogWarning("CustomPhysicsTable") << "Physics constructor being overwritten"
71  << " in CustomPhysicsTable";
72  TheCustomPhysicsTable->theTable[Factory->GetName()] = Factory;
73  MF_LOG_DEBUG("CustomPhysicsTable")
74  << "CustomPhysicsTable : Physics Table registering new physics " << Factory->GetName();
75  }
76 
77 }
G4VPhysicsConstructor * GetPhysicsConstructor(std::string const &physicsName)
std::vector< std::string > GetAvailablePhysicsList()
void AddPhysics(CustomPhysicsFactoryBase *)
std::map< std::string, CustomPhysicsFactoryBase * > theTable
std::string const & GetName() const noexcept
bool IsPhysicsAvailable(std::string const &)
static CustomPhysicsTable * TheCustomPhysicsTable