ParticlePropertiesFactory.cc
Go to the documentation of this file.
1 
9 #include <utl/ParticlePropertiesFactory.h>
10 #include <utl/VParticleProperties.h>
11 #include <utl/ParticleProperties.h>
12 #include <utl/NucleusProperties.h>
13 #include <utl/Particle.h>
14 #include <utl/PhysicalConstants.h>
15 #include <utl/ErrorLogger.h>
16 #include <sstream>
17 
18 
19 namespace utl {
20 
21  namespace {
22 
24  void
25  RegisterOneParticle(const int type,
26  const char* const name,
27  const double mass)
28  {
29  ParticlePropertiesCreator c(new ParticleProperties(type, name, mass));
31  std::ostringstream msg;
32  msg << "Registration of particle type " << type << " with name " << name << " failed.";
33  FATAL(msg);
34  throw ParticleTypeException(msg.str());
35  }
36  }
37 
38 
39  void
40  RegisterAllParticleProperties()
41  {
43  }
44 
45  }
46 
47 
50  {
52  RegisterAllParticleProperties();
54  } else if (NucleusProperties::IsNucleus(type)) {
55  return ParticlePropertiesPtr(new NucleusProperties(type));
56  } else {
57  std::ostringstream msg;
58  msg << "Cannot create particle properties for particle id " << type << '.';
59  FATAL(msg);
60  throw ParticleTypeException(msg.str());
61  }
62  }
63 
64 }
Class to hold properties of nuclei.
#define FATAL(message)
Macro for logging fatal messages.
Definition: ErrorLogger.h:167
boost::shared_ptr< const VParticleProperties > ParticlePropertiesPtr
static ParticlePropertiesPtr Unregistered(const int type)
static unsigned int GetNumberOfCreators()
Get number of object types know to this factory.
Definition: ObjectFactory.h:98
Base class to report non-existing particle id&#39;s.
Definition: Particle.h:180
static bool Register(const IdentifierType &id, const CreatorType &creator)
Register a factory function with an ID.
Definition: ObjectFactory.h:89
RegisterOneParticle(Particle::eUndefined,"Undefined", 0)
static ObjectPtrType Create(const IdentifierType &id)
Create an object (0-argument constructor)
static bool IsNucleus(const int type)
Check if type code is a valid nucleus.

, generated on Tue Sep 26 2023.