File indexing completed on 2025-04-19 09:09:56
0001 #ifndef ATOOLS_Phys_Flavour_H
0002 #define ATOOLS_Phys_Flavour_H
0003
0004 #define kf_code long unsigned int
0005 #define kf_none 0
0006
0007 #include "ATOOLS/Phys/Flavour_Tags.H"
0008 #include "ATOOLS/Math/MathTools.H"
0009
0010 #include <string>
0011 #include <vector>
0012 #include <set>
0013 #include <iostream>
0014 #include <map>
0015
0016 namespace ATOOLS {
0017
0018 class Flavour;
0019 class Mass_Selector;
0020
0021 typedef std::vector<Flavour*> PFlavour_Vector;
0022
0023 struct Particle_Info {
0024 public:
0025
0026 kf_code m_kfc;
0027 double m_mass, m_hmass, m_radius, m_yuk, m_width, m_dg, m_dm, m_qoverp2;
0028 int m_icharge, m_strong, m_resummed, m_priority;
0029 int m_spin, m_stable, m_masssign, m_dummy, m_majorana, m_formfactor;
0030 bool m_on, m_massive, m_hadron, m_isgroup;
0031
0032 std::string m_idname, m_antiname, m_texname, m_antitexname;
0033
0034 PFlavour_Vector m_content;
0035
0036 public:
0037
0038
0039 inline Particle_Info():
0040 m_kfc(kf_none), m_mass(0.0), m_radius(0.0), m_hmass(0.0), m_yuk(-1.0), m_width(0.0),
0041 m_dg(0.0), m_dm(0.0), m_qoverp2(1.0), m_icharge(0),
0042 m_strong(0), m_resummed(0), m_priority(0), m_spin(0), m_stable(1),
0043 m_masssign(0), m_dummy(1), m_majorana(0), m_formfactor(0), m_on(0),
0044 m_massive(0), m_hadron(0), m_isgroup(0) {}
0045 Particle_Info(const Particle_Info &info);
0046 Particle_Info(const kf_code &kfc,const double &mass,const double &radius,const double &width,
0047 const int icharge,const int strong,
0048 const int spin,const int majorana,const bool on,
0049 const int stable,bool massive,const std::string &idname,
0050 const std::string &antiname, const std::string &texname,
0051 const std::string &antitexname ,const bool dummy=0,
0052 const bool isgroup=false);
0053 Particle_Info(const kf_code &kfc,const double &mass,const double &radius,const double &width,
0054 const int icharge,const int spin,
0055 const bool on,const int stable,const std::string &idname,
0056 const std::string &texname);
0057 Particle_Info(const kf_code &kfc,const double &mass,const double &radius,const int icharge,
0058 const int spin,const int formfactor,const std::string &idname,
0059 const std::string &texname);
0060
0061 ~Particle_Info();
0062
0063
0064 bool Includes(const Flavour &fl) const;
0065
0066 void Add(const Flavour &fl);
0067 void Clear();
0068
0069 Flavour operator[](const size_t &i) const;
0070
0071 inline size_t Size() const { return m_content.size(); }
0072 inline bool Group() const { return m_isgroup||m_content.size()>1; }
0073 inline void SetIsGroup(bool isgroup) { m_isgroup = isgroup; };
0074
0075 void SetResummed();
0076
0077 };
0078
0079 class Flavour {
0080
0081 private:
0082
0083 void InitializeParticleInfo(const kf_code);
0084
0085 protected:
0086
0087 Particle_Info *p_info;
0088
0089 int m_anti;
0090
0091 friend std::ostream &operator<<(std::ostream &os, const Flavour &fl);
0092
0093 public:
0094
0095 Flavour(Particle_Info&, bool anti=0);
0096 Flavour(long int kfc=kf_none);
0097 Flavour(kf_code kfc, bool anti);
0098 Flavour(const Flavour& fl);
0099
0100
0101 std::string IDName() const;
0102 std::string ShellName() const;
0103 std::string LegacyShellName() const;
0104 std::string TexName() const;
0105 std::string RootName() const;
0106
0107 bool IsDiQuark() const;
0108 bool IsBaryon() const;
0109 bool IsMeson() const;
0110 bool IsNucleon() const;
0111 bool IsB_Hadron() const;
0112 bool IsC_Hadron() const;
0113
0114 double GenerateLifeTime() const;
0115 double RelBWMass(const double& min, const double& max,
0116 double peak=-1.0, double width=-1.0) const;
0117
0118
0119
0120
0121 static double ISSymmetryFactor(const std::vector<Flavour>& flavs);
0122 static double FSSymmetryFactor(const std::vector<Flavour>& flavs);
0123
0124
0125 inline Flavour Bar() const { return Flavour(*p_info,!m_anti); }
0126
0127 inline kf_code Kfcode() const { return p_info->m_kfc; }
0128
0129 inline size_t Size() const { return p_info->Size(); }
0130 inline size_t IsGroup() const { return p_info->Group(); }
0131
0132 inline bool Includes(const Flavour &fl) const
0133 {
0134 if (p_info->Group()) return p_info->Includes(fl);
0135 return p_info==fl.p_info && m_anti==fl.m_anti;
0136 }
0137
0138 inline Flavour operator[](const size_t &i) const
0139 {
0140 if (!p_info->Group()) return *this;
0141 return m_anti?(*p_info)[i].Bar():(*p_info)[i];
0142 }
0143
0144 inline bool operator==(const Flavour &fl) const
0145 { return p_info==fl.p_info && m_anti==fl.m_anti; }
0146
0147 inline operator long int() const
0148 { return m_anti?-(long int)Kfcode():(long int)Kfcode(); }
0149
0150 inline Flavour &operator=(const Flavour& fl)
0151 { if (this!=&fl) { p_info=fl.p_info; m_anti=fl.m_anti; } return *this; }
0152
0153 inline bool IsAnti() const { return m_anti; }
0154
0155 inline int IntCharge() const
0156 { int iq(p_info->m_icharge); return m_anti?-iq:iq; }
0157 inline double Charge() const
0158 { double c(p_info->m_icharge/3.0); return m_anti?-c:c; }
0159 inline bool IsQED() const
0160 { return (IsPhoton()||IntCharge());}
0161
0162 inline double IsoWeak() const
0163 { double c((p_info->m_kfc<7 || (p_info->m_kfc>10 && p_info->m_kfc<17))
0164 ?((p_info->m_kfc%2)?-0.5:0.5):0); return m_anti?-c:c; }
0165
0166 Flavour IsoWeakPartner() const;
0167 Flavour GoldstoneBosonPartner() const;
0168
0169 inline int StrongCharge() const
0170 { int c(p_info->m_strong); return m_anti?-c:c; }
0171 inline bool Strong() const
0172 { return p_info->m_strong!=0&&!IsDiQuark(); }
0173 inline bool IsQCD() const
0174 { return p_info->m_strong; }
0175
0176 inline bool Resummed() const
0177 { return p_info->m_resummed; }
0178
0179 inline int Priority() const
0180 { return p_info->m_priority; }
0181
0182 inline int IntSpin() const { return p_info->m_spin; }
0183 inline double Spin() const { return p_info->m_spin/2.0; }
0184
0185 inline bool SelfAnti() const { return p_info->m_majorana!=0; }
0186 inline bool Majorana() const { return p_info->m_majorana==1; }
0187
0188 inline int FormFactor() const {return p_info->m_formfactor; }
0189
0190 inline bool IsIon() const { return p_info->m_kfc>1000000000; }
0191
0192 inline int GetAtomicNumber() const { return (p_info->m_kfc/10)%1000; }
0193
0194 inline void SetOn(const bool on) const { p_info->m_on=on; }
0195
0196 inline bool IsOn() const { return p_info->m_on; }
0197
0198 inline void SetStable(const int stable) const
0199 { p_info->m_stable=stable; }
0200
0201 inline int Stable() const { return p_info->m_stable; }
0202 bool IsStable() const;
0203
0204 inline void SetMassOn(const bool on) const
0205 { p_info->m_massive=on; }
0206
0207 inline void SetMass(const double &mass) const
0208 { p_info->m_mass=dabs(mass);
0209 p_info->m_masssign = mass < 0.0 ? -1 : 1; }
0210
0211 inline void SetHadMass(const double &hmass) const
0212 { p_info->m_hmass=hmass; }
0213
0214 inline bool IsMassive() const
0215 { return p_info->m_mass?p_info->m_massive:0; }
0216
0217 inline void SetRadius(const double & radius)
0218 { p_info->m_radius=radius; }
0219
0220 inline double Mass(const bool set=0) const
0221 { return set||p_info->m_massive?p_info->m_mass:0.0; }
0222 inline double SelMass() const
0223 { return p_info->m_massive&&!IsKK()?p_info->m_mass:0.0; }
0224 inline double Radius() const
0225 { return p_info->m_radius ;}
0226 inline double HadMass() const
0227 { return p_info->m_hmass; }
0228 inline double Yuk() const
0229 { return p_info->m_yuk>=0.0 ? p_info->m_yuk : (p_info->m_massive ? p_info->m_mass : 0.0); }
0230 inline double DeltaGamma() const
0231 { return p_info->m_dg; }
0232 inline void SetDeltaGamma(double dgamma) const
0233 { p_info->m_dg = dgamma; }
0234 inline double DeltaM() const
0235 { return p_info->m_dm; }
0236 inline void SetDeltaM(double dm) const
0237 { p_info->m_dm = dm; }
0238 inline double QOverP2() const
0239 { return p_info->m_qoverp2; }
0240 inline void SetQOverP2(double qoverp2) const
0241 { p_info->m_qoverp2 = qoverp2; }
0242 inline int MassSign() const { return p_info->m_masssign; }
0243
0244 inline void SetWidth(const double &width) const
0245 { p_info->m_width=width; }
0246
0247 inline double Width() const
0248 { return p_info->m_width; }
0249
0250 inline bool IsHadron() const { return p_info->m_hadron; }
0251
0252 inline bool IsFermion() const { return IntSpin()==1; }
0253 inline bool IsBoson() const { return IntSpin()%2==0; }
0254 inline bool IsScalar() const { return IntSpin()==0; }
0255 inline bool IsVector() const { return IntSpin()==2; }
0256 inline bool IsRaritaSchwinger() const { return IntSpin()==3; }
0257 inline bool IsTensor() const { return IntSpin()==4; }
0258
0259 inline int LeptonFamily() const
0260 { if (IsLepton()) return (Kfcode()-9)/2; return 0; }
0261 inline int QuarkFamily() const
0262 { if (IsQuark()) return (Kfcode()+1)/2; return 0; }
0263
0264 inline bool IsPhoton() const { return Kfcode()==kf_photon; }
0265 inline bool IsLepton() const { return Kfcode()>10&&Kfcode()<19; }
0266 inline bool IsChargedLepton() const { return IsLepton()&&IsDowntype(); }
0267 inline bool IsNeutrino() const { return IsLepton()&&IsUptype(); }
0268
0269 inline bool IsQuark() const { return Kfcode()<10; }
0270 inline bool IsGluon() const
0271 { return Kfcode()==kf_gluon||Kfcode()==kf_shgluon; }
0272 inline bool IsJet() const { return Kfcode()==kf_jet; }
0273
0274 inline bool IsUptype() const { return IsAnti()?IsoWeak()<0:IsoWeak()>0; }
0275 inline bool IsDowntype() const { return IsAnti()?IsoWeak()>0:IsoWeak()<0; }
0276
0277 inline bool IsKK() const
0278 { if (Kfcode()==kf_graviton || Kfcode()==kf_gscalar) return 1;
0279 return 0; }
0280 inline int KKGeneration() const
0281 { if (!IsKK()) return 0;
0282 return (Kfcode()-1000000*(Kfcode()/1000000))/100000; }
0283
0284 inline bool IsDummy() const
0285 { return p_info->m_dummy; }
0286
0287 inline bool operator<(const Flavour &f) const
0288 {
0289 if (Kfcode()<f.Kfcode()) return true;
0290 if (Kfcode()>f.Kfcode()) return false;
0291 return m_anti<f.m_anti;
0292 }
0293
0294 };
0295
0296 std::ostream &operator<<(std::ostream &os, const Flavour &fl);
0297
0298 typedef std::vector<Flavour> Flavour_Vector;
0299 typedef std::map<Flavour,Flavour> Flavour_Map;
0300 typedef std::set<Flavour> Flavour_Set;
0301
0302 class Mass_Selector {
0303 public:
0304 virtual ~Mass_Selector();
0305 virtual double Mass(const Flavour &fl) const = 0;
0306 inline double Mass2(const Flavour &fl) const {
0307 double m(Mass(fl)); return m*m;
0308 }
0309 };
0310
0311 }
0312
0313 #endif