OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
21#include "Utilities/BiMap.h"
22
24 auto it = bmParticleType_s.right.find(str);
25 if (it != bmParticleType_s.right.end()) {
26 return it->second;
27 } else {
29 }
30}
31
33 return bmParticleType_s.left.at(type);
34}
35
37 return particleMass_m.at(type);
38}
39
41 return particleCharge_m.at(type);
42}
43
47
49 auto it = particleLifetime_m.find(type);
50 if (it != particleLifetime_m.end()) {
51 return it->second;
52 }
53 throw std::runtime_error(
54 "ParticleProperties::getParticleLifetime: no lifetime for particle \""
55 + getParticleTypeString(type) + "\" (stable or unsupported).");
56}
57
59 switch (type) {
60 case ParticleType::ELECTRON: // jumps to POSITRON case
62 return Physics::a_e;
64 return Physics::a_mu;
65 case ParticleType::PROTON: // jumps to ANTIPROTON case
67 return Physics::a_p;
68 default:
69 return 0.0;
70 }
71}
72
75 bimap.insert(ParticleType::UNNAMED, "UNNAMED");
76 bimap.insert(ParticleType::PHOTON, "PHOTON");
77 bimap.insert(ParticleType::ELECTRON, "ELECTRON");
78 bimap.insert(ParticleType::POSITRON, "POSITRON");
79 bimap.insert(ParticleType::MUON, "MUON");
80 bimap.insert(ParticleType::PION, "PION");
81 bimap.insert(ParticleType::PROTON, "PROTON");
82 bimap.insert(ParticleType::ANTIPROTON, "ANTIPROTON");
83 bimap.insert(ParticleType::DEUTERON, "DEUTERON");
84 bimap.insert(ParticleType::HMINUS, "HMINUS");
85 bimap.insert(ParticleType::HYDROGEN, "HYDROGEN");
86 bimap.insert(ParticleType::H2P, "H2P");
87 bimap.insert(ParticleType::H3P, "H3P");
88 bimap.insert(ParticleType::ALPHA, "ALPHA");
89 bimap.insert(ParticleType::CARBON, "CARBON");
90 bimap.insert(ParticleType::XENON, "XENON");
91 bimap.insert(ParticleType::URANIUM, "URANIUM");
92 return bimap;
93}();
94
95const std::map<ParticleType, double> ParticleProperties::particleMass_m = {
112
113const std::map<ParticleType, double> ParticleProperties::particleCharge_m = {
122
123const std::map<ParticleType, double> ParticleProperties::particleLifetime_m = {
Simple bidirectional map with lookup in both directions.
Definition BiMap.h:28
void insert(const Left &left, const Right &right)
Insert or overwrite a left/right association.
Definition BiMap.h:99
right_view right
Right view accessor.
Definition BiMap.h:94
left_view left
Left view accessor.
Definition BiMap.h:92
static std::string getParticleTypeString(const ParticleType &type)
static double getParticleMass(const ParticleType &type)
static const std::map< ParticleType, double > particleCharge_m
static const BiMap< ParticleType, std::string > bmParticleType_s
static double getParticleCharge(const ParticleType &type)
static const std::map< ParticleType, double > particleMass_m
static double getParticleAnomaly(const ParticleType &type)
static double getParticleChargeInCoulomb(const ParticleType &type)
static double getParticleLifetime(const ParticleType &type)
Return the mean rest-frame lifetime [s]. Throws if the particle is stable.
static const std::map< ParticleType, double > particleLifetime_m
static ParticleType getParticleType(const std::string &str)
constexpr double m_xe
The xenon-129 (fully-stripped) rest mass in GeV.
Definition Physics.h:147
constexpr double m_alpha
The alpha particle rest mass in GeV.
Definition Physics.h:150
constexpr double m_u
The uranium-238 (fully-stripped) rest mass in GeV.
Definition Physics.h:126
constexpr double a_mu
The magnetic moment anomaly for muons, no dimension (PDG, (g-2)/2)
Definition Physics.h:135
constexpr double a_p
The magnetic momentum anomaly for protons, no dimension.
Definition Physics.h:114
constexpr double m_pi
The charged pion rest mass in GeV (PDG)
Definition Physics.h:138
constexpr double m_p
The proton rest mass in GeV.
Definition Physics.h:105
constexpr double m_h3p
The H3+ rest mass in GeV.
Definition Physics.h:159
constexpr double m_h2p
The H2+ rest mass in GeV.
Definition Physics.h:156
constexpr double tau_mu
Muon mean lifetime at rest [s] (PDG)
Definition Physics.h:132
constexpr double q_e
The elementary charge in As.
Definition Physics.h:84
constexpr double a_e
The magnetic momentum anomaly for electrons, no dimension.
Definition Physics.h:102
constexpr double m_e
The electron rest mass in GeV.
Definition Physics.h:93
constexpr double m_hm
The H- rest mass in GeV.
Definition Physics.h:123
constexpr double m_h
The hydrogen atom rest mass in GeV.
Definition Physics.h:153
constexpr double m_mu
The muon rest mass in GeV.
Definition Physics.h:129
constexpr double m_c
The carbon-12 (fully-stripped) rest mass in GeV.
Definition Physics.h:120
constexpr double m_d
The deuteron rest mass in GeV.
Definition Physics.h:144
constexpr double tau_pi
Charged pion mean lifetime at rest [s] (PDG)
Definition Physics.h:141