File indexing completed on 2024-11-15 09:38:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include <GaudiKernel/HashMap.h>
0014 #include <GaudiKernel/Kernel.h>
0015 #include <cmath>
0016 #include <cstdint>
0017 #include <iosfwd>
0018 #include <string>
0019 #include <tuple>
0020
0021 namespace Gaudi {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 class GAUDI_API ParticleID final {
0044 public:
0045
0046 enum Location { nj = 1, nq3, nq2, nq1, nl, nr, n, n8, n9, n10 };
0047
0048 enum Quark { down = 1, up, strange, charm, bottom, top, bottom_prime, top_prime, first = down, last = top_prime };
0049
0050
0051 explicit ParticleID( const int pid = 0 ) { setPid( pid ); }
0052
0053
0054 int pid() const { return m_pid; }
0055
0056 constexpr unsigned int abspid() const { return 0 > m_pid ? -m_pid : m_pid; }
0057
0058 void setPid( const int pid ) { m_pid = pid; }
0059
0060
0061 bool isValid() const;
0062
0063 bool isSM() const;
0064
0065 bool isMeson() const;
0066
0067 bool isBaryon() const;
0068
0069 bool isDiQuark() const;
0070
0071 bool isHadron() const;
0072
0073 bool isLepton() const;
0074
0075 bool isNucleus() const;
0076
0077 bool isQuark() const;
0078
0079
0080 bool hasQuarks() const;
0081
0082 bool hasQuark( const Quark& q ) const;
0083
0084 bool hasDown() const { return hasQuark( down ); }
0085
0086 bool hasUp() const { return hasQuark( up ); }
0087
0088 bool hasStrange() const { return hasQuark( strange ); }
0089
0090 bool hasCharm() const { return hasQuark( charm ); }
0091
0092 bool hasBottom() const { return hasQuark( bottom ); }
0093
0094 bool hasTop() const { return hasQuark( top ); }
0095
0096 bool hasBottomPrime() const { return hasQuark( bottom_prime ); }
0097
0098 bool hasTopPrime() const { return hasQuark( top_prime ); }
0099
0100
0101 int threeCharge() const;
0102
0103 int jSpin() const;
0104
0105 int sSpin() const;
0106
0107 int lSpin() const;
0108
0109
0110 int Z() const;
0111
0112 int A() const;
0113
0114 int nLambda() const;
0115
0116
0117
0118
0119
0120 int fundamentalID() const;
0121
0122
0123 int extraBits() const;
0124
0125 constexpr unsigned short digit( const Location& loc ) const {
0126 constexpr std::uint32_t pows[10] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
0127 return ( abspid() / pows[loc - 1] ) % 10;
0128 }
0129
0130
0131 bool operator==( const ParticleID& o ) const { return m_pid == o.m_pid; }
0132
0133 bool operator!=( const ParticleID& o ) const { return m_pid != o.m_pid; }
0134
0135 bool operator<( const ParticleID& o ) const {
0136 const unsigned int i1( abspid() ), i2( o.abspid() );
0137 return std::tie( i1, m_pid ) < std::tie( i2, o.m_pid );
0138 }
0139
0140
0141 std::ostream& fillStream( std::ostream& s ) const;
0142
0143 std::string toString() const;
0144
0145 static std::ostream& printLocation( const long l, std::ostream& s );
0146
0147 static std::string printLocation( const long l );
0148
0149 static std::ostream& printQuark( const long q, std::ostream& s );
0150
0151 static std::string printQuark( const long q );
0152
0153 private:
0154
0155 int m_pid{ 0 };
0156 };
0157
0158
0159
0160 inline std::ostream& operator<<( std::ostream& s, const Gaudi::ParticleID& o ) { return o.fillStream( s ); }
0161
0162 inline std::ostream& operator<<( std::ostream& s, Gaudi::ParticleID::Location l ) {
0163 return Gaudi::ParticleID::printLocation( l, s );
0164 }
0165
0166 inline std::ostream& operator<<( std::ostream& s, Gaudi::ParticleID::Quark q ) {
0167 return Gaudi::ParticleID::printQuark( q, s );
0168 }
0169 }
0170
0171 namespace GaudiUtils {
0172 template <>
0173 struct Hash<Gaudi::ParticleID> {
0174 inline size_t operator()( const Gaudi::ParticleID& s ) const { return (size_t)s.pid(); }
0175 };
0176 template <>
0177 struct Hash<const Gaudi::ParticleID> {
0178 inline size_t operator()( const Gaudi::ParticleID& s ) const { return (size_t)s.pid(); }
0179 };
0180 template <>
0181 struct Hash<Gaudi::ParticleID&> {
0182 inline size_t operator()( const Gaudi::ParticleID& s ) const { return (size_t)s.pid(); }
0183 };
0184 template <>
0185 struct Hash<const Gaudi::ParticleID&> {
0186 inline size_t operator()( const Gaudi::ParticleID& s ) const { return (size_t)s.pid(); }
0187 };
0188 }
0189 namespace std {
0190
0191 inline Gaudi::ParticleID abs( const Gaudi::ParticleID& p ) { return Gaudi::ParticleID( p.abspid() ); }
0192 }