File indexing completed on 2026-05-23 07:34:14
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/ParticleData.hpp"
0012 #include "Acts/Definitions/PdgParticle.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/EventData/ChargeHypothesis.hpp"
0015
0016 #include <cassert>
0017 #include <iostream>
0018
0019 namespace Acts {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class ParticleHypothesis final {
0034 public:
0035
0036
0037 static ParticleHypothesis muon() {
0038 static const ParticleHypothesis cache(PdgParticle::eMuon);
0039 return cache;
0040 }
0041
0042
0043 static ParticleHypothesis pion() {
0044 static const ParticleHypothesis cache(PdgParticle::ePionPlus);
0045 return cache;
0046 }
0047
0048
0049 static ParticleHypothesis electron() {
0050 static const ParticleHypothesis cache(PdgParticle::eElectron);
0051 return cache;
0052 }
0053
0054
0055 static ParticleHypothesis kaon() {
0056 static const ParticleHypothesis cache(PdgParticle::eKaonPlus);
0057 return cache;
0058 }
0059
0060
0061 static ParticleHypothesis proton() {
0062 static const ParticleHypothesis cache(PdgParticle::eProton);
0063 return cache;
0064 }
0065
0066
0067
0068 static ParticleHypothesis photon() {
0069 static const ParticleHypothesis cache(PdgParticle::eGamma);
0070 return cache;
0071 }
0072
0073
0074 static ParticleHypothesis pion0() {
0075 static const ParticleHypothesis cache(PdgParticle::ePionZero);
0076 return cache;
0077 }
0078
0079
0080
0081
0082 static ParticleHypothesis pionLike(float absoluteCharge) {
0083 return ParticleHypothesis(pion().absolutePdg(), pion().mass(),
0084 ChargeHypothesis{absoluteCharge});
0085 }
0086
0087
0088
0089 static ParticleHypothesis geantino() {
0090 ParticleHypothesis cache(PdgParticle::eInvalid, 0, ChargeHypothesis{0});
0091 return cache;
0092 }
0093
0094
0095 static ParticleHypothesis chargedGeantino() {
0096 static const auto cache = chargedGeantino(Acts::UnitConstants::e);
0097 return cache;
0098 }
0099
0100
0101
0102 static ParticleHypothesis chargedGeantino(float absoluteCharge) {
0103 return ParticleHypothesis(PdgParticle::eInvalid, 0,
0104 ChargeHypothesis{absoluteCharge});
0105 }
0106
0107
0108
0109
0110
0111
0112
0113 constexpr ParticleHypothesis(PdgParticle absPdg, float mass, float absCharge)
0114 : m_absPdg{absPdg}, m_mass{mass}, m_charge{absCharge} {
0115 assert(absPdg == makeAbsolutePdgParticle(absPdg) &&
0116 "pdg is expected to be absolute");
0117 }
0118
0119
0120
0121
0122
0123
0124
0125 constexpr ParticleHypothesis(PdgParticle absPdg, float mass,
0126 ChargeHypothesis charge)
0127 : m_absPdg{absPdg}, m_mass{mass}, m_charge{charge} {
0128 assert(absPdg == makeAbsolutePdgParticle(absPdg) &&
0129 "pdg is expected to be absolute");
0130 }
0131
0132
0133
0134
0135
0136
0137 explicit ParticleHypothesis(PdgParticle absPdg)
0138 : m_absPdg{absPdg},
0139 m_mass{findMass(absPdg).value()},
0140 m_charge{std::abs(findCharge(absPdg).value())} {
0141 assert(absPdg == makeAbsolutePdgParticle(absPdg) &&
0142 "pdg is expected to be absolute");
0143 }
0144
0145
0146
0147 constexpr PdgParticle absolutePdg() const noexcept { return m_absPdg; }
0148
0149
0150
0151 constexpr float mass() const noexcept { return m_mass; }
0152
0153
0154
0155 float absoluteCharge() const noexcept { return m_charge.absoluteCharge(); }
0156
0157
0158
0159
0160
0161
0162 constexpr float extractCharge(double qOverP) const noexcept {
0163 return m_charge.extractCharge(qOverP);
0164 }
0165
0166
0167
0168
0169
0170
0171 constexpr double extractMomentum(double qOverP) const noexcept {
0172 return m_charge.extractMomentum(qOverP);
0173 }
0174
0175
0176
0177
0178
0179
0180
0181 constexpr double qOverP(double momentum, float signedQ) const noexcept {
0182 return m_charge.qOverP(momentum, signedQ);
0183 }
0184
0185
0186
0187 constexpr const ChargeHypothesis& charge() const noexcept { return m_charge; }
0188
0189
0190
0191
0192 std::ostream& toStream(std::ostream& os) const {
0193 os << "ParticleHypothesis{absPdg=";
0194 if (auto shortString = pdgToShortAbsString(absolutePdg())) {
0195 os << *shortString;
0196 } else {
0197 os << absolutePdg();
0198 }
0199 os << ", mass=" << mass() << ", absCharge=" << absoluteCharge() << "}";
0200 return os;
0201 }
0202
0203
0204
0205
0206
0207 friend std::ostream& operator<<(
0208 std::ostream& os, const ParticleHypothesis& particleHypothesis) {
0209 return particleHypothesis.toStream(os);
0210 }
0211
0212 private:
0213 PdgParticle m_absPdg{PdgParticle::eInvalid};
0214 float m_mass{0};
0215 ChargeHypothesis m_charge;
0216
0217 friend bool operator==(const ParticleHypothesis& lhs,
0218 const ParticleHypothesis& rhs) = default;
0219 };
0220
0221
0222
0223 }