OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
ParticleProperties.cpp
Go to the documentation of this file.
1//
2// Class ParticleProperties
3// Base class for representing particle properties
4//
5// Copyright (c) 2021, Pedro Calvo, CIEMAT, Spain
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
19#include "Physics/Physics.h"
20#include "Utilities/Util.h"
21
22ParticleType ParticleProperties::getParticleType(std::string_view str) noexcept {
23 return Util::stringToEnum(str, particleTypeMap, ParticleType::UNNAMED);
24}
25
27 return std::string(Util::enumToString(type, particleTypeMap, "UNNAMED"));
28}
29
31 return particleMass_m.at(type);
32}
33
35 return particleCharge_m.at(type);
36}
37
41
42const std::array<std::pair<ParticleType, std::string_view>, 15>
44 {ParticleType::UNNAMED, "UNNAMED"},
45 {ParticleType::ELECTRON, "ELECTRON"},
46 {ParticleType::POSITRON, "POSITRON"},
47 {ParticleType::MUON, "MUON"},
48 {ParticleType::PROTON, "PROTON"},
49 {ParticleType::ANTIPROTON, "ANTIPROTON"},
50 {ParticleType::DEUTERON, "DEUTERON"},
51 {ParticleType::HMINUS, "HMINUS"},
52 {ParticleType::HYDROGEN, "HYDROGEN"},
53 {ParticleType::H2P, "H2P"},
54 {ParticleType::H3P, "H3P"},
55 {ParticleType::ALPHA, "ALPHA"},
56 {ParticleType::CARBON, "CARBON"},
57 {ParticleType::XENON, "XENON"},
58 {ParticleType::URANIUM, "URANIUM"}
59}};
60
61const std::map<ParticleType, double> ParticleProperties::particleMass_m = {
76};
77
78const std::map<ParticleType, double> ParticleProperties::particleCharge_m = {
81 {ParticleType::MUON, -1.0},
87 {ParticleType::H2P, 1.0},
88 {ParticleType::H3P, 1.0},
91 {ParticleType::XENON, 54.0},
93};
constexpr double m_xe
The xenon-129 (fully-stripped) rest mass in GeV.
Definition Physics.h:120
constexpr double m_alpha
The alpha particle rest mass in GeV.
Definition Physics.h:123
constexpr double m_u
The uranium-238 (fully-stripped) rest mass in GeV.
Definition Physics.h:111
constexpr double m_p
The proton rest mass in GeV.
Definition Physics.h:90
constexpr double m_h3p
The H3+ rest mass in GeV.
Definition Physics.h:132
constexpr double m_h2p
The H2+ rest mass in GeV.
Definition Physics.h:129
constexpr double q_e
The elementary charge in As.
Definition Physics.h:69
constexpr double m_e
The electron rest mass in GeV.
Definition Physics.h:78
constexpr double m_hm
The H- rest mass in GeV.
Definition Physics.h:108
constexpr double m_h
The hydrogen atom rest mass in GeV.
Definition Physics.h:126
constexpr double m_mu
The muon rest mass in GeV.
Definition Physics.h:114
constexpr double m_c
The carbon-12 (fully-stripped) rest mass in GeV.
Definition Physics.h:105
constexpr double m_d
The deuteron rest mass in GeV.
Definition Physics.h:117
constexpr Enum stringToEnum(std::string_view str, const std::array< std::pair< Enum, std::string_view >, N > &map, Enum defaultEnum) noexcept
Definition Util.h:237
constexpr std::string_view enumToString(Enum e, const std::array< std::pair< Enum, std::string_view >, N > &map, std::string_view defaultStr) noexcept
Definition Util.h:247
static ParticleType getParticleType(std::string_view str) noexcept
static double getParticleMass(const ParticleType &type)
static const std::map< ParticleType, double > particleCharge_m
static std::string getParticleTypeString(const ParticleType &type) noexcept
static double getParticleCharge(const ParticleType &type)
static const std::array< std::pair< ParticleType, std::string_view >, 15 > particleTypeMap
static const std::map< ParticleType, double > particleMass_m
static double getParticleChargeInCoulomb(const ParticleType &type)