NucleusProperties.cc
Go to the documentation of this file.
1 #include <utl/NucleusProperties.h>
2 #include <utl/Particle.h>
3 #include <utl/PhysicalConstants.h>
4 #include <utl/Math.h>
5 #include <boost/format.hpp>
6 
7 using boost::format;
8 using boost::io::str;
9 
10 
11 namespace {
12 
13  const char* gNuclearNames[] = {
14  "neutron",
15  "H",
16  "He",
17  "Li",
18  "Be",
19  "B",
20  "C",
21  "N",
22  "O",
23  "F",
24  "Ne",
25  "Na",
26  "Mg",
27  "Al",
28  "Si",
29  "P",
30  "S",
31  "Cl",
32  "Ar",
33  "K",
34  "Ca",
35  "Sc",
36  "Ti",
37  "V",
38  "Cr",
39  "Mn",
40  "Fe"
41  };
42 
43  unsigned int kMaxNuclearNameIndex = utl::Length(gNuclearNames) - 1;
44 
45 }
46 
47 
48 namespace utl {
49 
50  std::string
52  const
53  {
54  const unsigned int z = (fType / kChargeFactor) % kChargeMask;
55  const unsigned int a = (fType / kAtomicNumberFactor) % kAtomicNumberMask;
56 
57  return (z <= kMaxNuclearNameIndex) ?
58  str(format("%1% %2%") % gNuclearNames[z] % a) :
59  str(format("N(%1%) %2%") % z % a);
60  }
61 
62 
63  double
65  const
66  {
68  }
69 
70 
77  double
79  const
80  {
81  return GetAtomicNumber() * kProtonMass;
82  }
83 
84 
85  int
86  NucleusProperties::TypeCode(const unsigned int charge,
87  const unsigned int atomicNumber)
88  {
89  return
91  + kChargeFactor * charge
92  + kAtomicNumberFactor * atomicNumber;
93  }
94 
95 
97  bool
99  {
100  return kNucleusBase < type && type < kNucleusMax;
101  }
102 
103 }
virtual double GetAtomicNumber() const
Get atomic mass number A of particle.
constexpr double kProtonMass
static const int kChargeFactor
virtual double GetMass() const override
Get particle mass (in Auger units)
static const int kAtomicNumberMask
static const int kNucleusBase
static const int kAtomicNumberFactor
static int TypeCode(const unsigned int charge, const unsigned int atomicNumber)
Calculate the particle type code from Z and A.
static const int kChargeMask
static const int kNucleusMax
static bool IsNucleus(const int type)
Check if type code is a valid nucleus.
virtual std::string GetName() const override
Get particle name.

, generated on Tue Sep 26 2023.