File indexing completed on 2025-07-15 08:11:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <cmath>
0012 #include <cstdint>
0013 #include <stdexcept>
0014 #include <utility>
0015
0016 namespace Acts {
0017
0018
0019 enum PdgParticle : std::int32_t {
0020 eInvalid = 0,
0021 eElectron = 11,
0022 eAntiElectron = -eElectron,
0023 ePositron = -eElectron,
0024 eMuon = 13,
0025 eAntiMuon = -eMuon,
0026 eTau = 15,
0027 eAntiTau = -eTau,
0028 eGamma = 22,
0029 ePionZero = 111,
0030 ePionPlus = 211,
0031 ePionMinus = -ePionPlus,
0032 eKaonPlus = 321,
0033 eKaonMinus = -eKaonPlus,
0034 eNeutron = 2112,
0035 eAntiNeutron = -eNeutron,
0036 eProton = 2212,
0037 eAntiProton = -eProton,
0038 eLead = 1000822080
0039 };
0040
0041
0042 static constexpr PdgParticle makeAbsolutePdgParticle(PdgParticle pdg) {
0043 const auto value = static_cast<std::int32_t>(pdg);
0044 return static_cast<PdgParticle>((0 <= value) ? value : -value);
0045 }
0046
0047
0048
0049
0050 static constexpr bool isNucleus(PdgParticle pdg) {
0051 const auto pdgNum = static_cast<std::int32_t>(pdg);
0052 return std::abs(pdgNum) > 1e9;
0053 }
0054
0055
0056
0057
0058
0059 static constexpr PdgParticle makeNucleusGroundState(PdgParticle pdg) {
0060 if (!isNucleus(pdg)) {
0061 throw std::invalid_argument("PDG must represent a nucleus");
0062 }
0063 const auto pdgNum = static_cast<std::int32_t>(pdg);
0064
0065 return static_cast<PdgParticle>((pdgNum / 10) * 10);
0066 }
0067
0068
0069
0070
0071
0072
0073 static constexpr std::pair<std::int32_t, std::int32_t> extractNucleusZandA(
0074 PdgParticle pdg) {
0075 if (!isNucleus(pdg)) {
0076 throw std::invalid_argument("PDG must represent a nucleus");
0077 }
0078 const auto pdgNum = static_cast<std::int32_t>(pdg);
0079
0080 int Z = (pdgNum / 10000) % 1000;
0081
0082 int A = std::abs((pdgNum / 10) % 1000);
0083 return std::make_pair(Z, A);
0084 }
0085
0086 }