All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CustomPhysicsFactory.hh
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file CustomPhysicsFactory.h
3 //
4 /// \author seligman@nevis.columbia.edu
5 ////////////////////////////////////////////////////////////////////////
6 #ifndef CUSTOMPHYSICSFACTORY_hh
7 #define CUSTOMPHYSICSFACTORY_hh
8 
9 #include "Geant4/G4VPhysicsConstructor.hh"
11 
12 namespace larg4 {
13  class CustomPhysicsTable;
14 
16  public:
17  explicit CustomPhysicsFactoryBase(std::string const& name) : fName{name}
18  {
19  if (empty(name))
20  std::cerr << "CustomPhysicsFactory Error : Physics registered with no name!" << std::endl;
21  }
22  virtual ~CustomPhysicsFactoryBase() = default;
23 
24  std::string const&
25  GetName() const noexcept
26  {
27  return fName;
28  }
29 
30  virtual G4VPhysicsConstructor* Build() const = 0;
31 
32  private:
33  std::string fName;
34  };
35 
36  template <class T>
38  public:
39  explicit CustomPhysicsFactory(std::string const& name);
40 
41  G4VPhysicsConstructor*
42  Build() const
43  {
44  return new T{};
45  }
46  };
47 
48  template <class T>
51  {
52  // register self in physics table - note, factory is actually registered
53  // in static TheCustomPhysicsTable, not the instance created below
54  // which just acts to pass information along
55  new CustomPhysicsTable(this);
56  }
57 }
58 
59 #endif
BEGIN_PROLOG could also be cerr
virtual G4VPhysicsConstructor * Build() const =0
CustomPhysicsFactory(std::string const &name)
CustomPhysicsFactoryBase(std::string const &name)
std::string const & GetName() const noexcept
virtual ~CustomPhysicsFactoryBase()=default
then echo fcl name
G4VPhysicsConstructor * Build() const
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555