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