File indexing completed on 2024-11-15 09:01:27
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/Utilities/Concepts.hpp"
0014
0015 #include <cassert>
0016 #include <ostream>
0017 #include <utility>
0018
0019 namespace Acts {
0020
0021
0022
0023
0024
0025 template <ACTS_CONCEPT(ChargeConcept) charge_t>
0026 class GenericParticleHypothesis {
0027 public:
0028 using ChargeType = charge_t;
0029
0030
0031
0032
0033
0034
0035
0036 constexpr GenericParticleHypothesis(PdgParticle absPdg, float mass,
0037 ChargeType chargeType)
0038 : m_absPdg{absPdg}, m_mass{mass}, m_chargeType{std::move(chargeType)} {
0039 assert(absPdg == makeAbsolutePdgParticle(absPdg) &&
0040 "pdg is expected to be absolute");
0041 }
0042
0043
0044
0045
0046
0047
0048 GenericParticleHypothesis(PdgParticle absPdg)
0049 : m_absPdg{absPdg},
0050 m_mass{findMass(absPdg).value()},
0051 m_chargeType{std::abs(findCharge(absPdg).value())} {
0052 assert(absPdg == makeAbsolutePdgParticle(absPdg) &&
0053 "pdg is expected to be absolute");
0054 }
0055
0056
0057
0058
0059 template <typename other_charge_t>
0060 constexpr GenericParticleHypothesis(
0061 const GenericParticleHypothesis<other_charge_t>& other)
0062 : m_absPdg{other.absolutePdg()},
0063 m_mass{other.mass()},
0064 m_chargeType{other.chargeType()} {}
0065
0066
0067 constexpr PdgParticle absolutePdg() const noexcept { return m_absPdg; }
0068
0069
0070 constexpr float mass() const noexcept { return m_mass; }
0071
0072
0073 constexpr float absoluteCharge() const noexcept {
0074 return m_chargeType.absQ();
0075 }
0076
0077
0078
0079
0080
0081 template <typename T>
0082 constexpr auto extractCharge(T qOverP) const noexcept {
0083 return m_chargeType.extractCharge(qOverP);
0084 }
0085
0086
0087
0088
0089
0090 template <typename T>
0091 constexpr auto extractMomentum(T qOverP) const noexcept {
0092 return m_chargeType.extractMomentum(qOverP);
0093 }
0094
0095
0096
0097
0098
0099
0100 template <typename P, typename Q>
0101 constexpr auto qOverP(P momentum, Q signedQ) const noexcept {
0102 return m_chargeType.qOverP(momentum, signedQ);
0103 }
0104
0105
0106 constexpr const ChargeType& chargeType() const noexcept {
0107 return m_chargeType;
0108 }
0109
0110 std::ostream& toStream(std::ostream& os) const {
0111 os << "ParticleHypothesis{absPdg=";
0112 if (auto shortString = pdgToShortAbsString(absolutePdg())) {
0113 os << *shortString;
0114 } else {
0115 os << absolutePdg();
0116 }
0117 os << ", mass=" << mass() << ", absCharge=" << absoluteCharge() << "}";
0118 return os;
0119 }
0120
0121 friend std::ostream& operator<<(
0122 std::ostream& os, const GenericParticleHypothesis& particleHypothesis) {
0123 return particleHypothesis.toStream(os);
0124 }
0125
0126 private:
0127 PdgParticle m_absPdg;
0128 float m_mass;
0129 ChargeType m_chargeType;
0130
0131 friend bool operator==(const GenericParticleHypothesis<ChargeType>& lhs,
0132 const GenericParticleHypothesis<ChargeType>& rhs) {
0133 return (lhs.m_absPdg == rhs.m_absPdg) && (lhs.m_mass == rhs.m_mass) &&
0134 (lhs.m_chargeType == rhs.m_chargeType);
0135 }
0136 friend bool operator!=(const GenericParticleHypothesis<ChargeType>& lhs,
0137 const GenericParticleHypothesis<ChargeType>& rhs) {
0138 return (lhs.m_absPdg != rhs.m_absPdg) || (lhs.m_mass != rhs.m_mass) ||
0139 (lhs.m_chargeType != rhs.m_chargeType);
0140 }
0141 };
0142
0143 }