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 
9 
12 
13 namespace larg4 {
14 
16 
17  //-----------------------------------------------------------------
19  {
20  if (!TheCustomPhysicsTable) {
21  TheCustomPhysicsTable = new CustomPhysicsTable;
22  TheCustomPhysicsTable->AddPhysics(Factory);
23  }
24  else {
25  TheCustomPhysicsTable->AddPhysics(Factory);
26  }
27  }
28 
29  //-----------------------------------------------------------------
30  std::vector<std::string>
32  {
33  std::vector<std::string> ReturnVector;
35  TheCustomPhysicsTable->theTable.begin();
36  i != TheCustomPhysicsTable->theTable.end();
37  i++) {
38  ReturnVector.push_back((*i).first);
39  }
40  return ReturnVector;
41  }
42 
43  //-----------------------------------------------------------------
44  bool
46  {
47  if (!TheCustomPhysicsTable->theTable[PhysicsName])
48  return false;
49  else
50  return true;
51  }
52 
53  //-----------------------------------------------------------------
54  G4VPhysicsConstructor*
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 }
std::string string
Definition: nybbler.cc:12
Geant4 interface.
intermediate_table::const_iterator const_iterator
G4VPhysicsConstructor * GetPhysicsConstructor(std::string const &physicsName)
std::vector< std::string > GetAvailablePhysicsList()
void AddPhysics(CustomPhysicsFactoryBase *)
std::map< std::string, CustomPhysicsFactoryBase * > theTable
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define MF_LOG_DEBUG(id)
bool IsPhysicsAvailable(std::string const &)
static CustomPhysicsTable * TheCustomPhysicsTable
std::string const & GetName() const noexcept