diff --git a/include/HEJ/PDG_codes.hh b/include/HEJ/PDG_codes.hh index b4bf475..a942130 100644 --- a/include/HEJ/PDG_codes.hh +++ b/include/HEJ/PDG_codes.hh @@ -1,102 +1,132 @@ /** \file PDG_codes.hh * \brief Contains the Particle IDs of all relevant SM particles. * * Large enumeration included which has multiple entries for potential * alternative names of different particles. There are also functions * which can be used to determine if a particle is a parton or if * it is a non-gluon boson. * * \authors Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie * \date 2019 * \copyright GPLv2 or later */ #pragma once #include namespace HEJ { //! particle ids according to PDG namespace pid { //! The possible particle identities. We use PDG IDs as standard. enum ParticleID{ d = 1, /*!< Down Quark */ down = d, /*!< Down Quark */ u = 2, /*!< Up Quark */ up = u, /*!< Up Quark */ s = 3, /*!< Strange Quark */ strange = s, /*!< Strange Quark */ c = 4, /*!< Charm Quark */ charm = c, /*!< Charm Quark */ b = 5, /*!< Bottom Quark */ bottom = b, /*!< Bottom Quark */ t = 6, /*!< Top Quark */ top = t, /*!< Top Quark */ e = 11, /*!< Electron */ electron = e, /*!< Electron */ nu_e = 12, /*!< Electron Neutrino */ electron_neutrino = nu_e, /*!< Electron neutrino */ mu = 13, /*!< Muon */ muon = mu, /*!< Muon */ nu_mu = 14, /*!< Muon Neutrino */ muon_neutrino = nu_mu, /*!< Muon Neutrino */ tau = 15, /*!< Tau */ nu_tau = 16, /*!< Tau Neutrino */ tau_neutrino = nu_tau, /*!< Tau Neutrino */ d_bar = -d, /*!< Anti-Down Quark */ u_bar = -u, /*!< Anti-Up quark */ s_bar = -s, /*!< Anti-Strange Quark */ c_bar = -c, /*!< Anti-Charm Quark */ b_bar = -b, /*!< Anti-Bottom Quark */ t_bar = -t, /*!< Anti-Top Quark */ e_bar = -e, /*!< Positron */ positron = e_bar, /*!< Positron */ nu_e_bar = -nu_e, /*!< Anti-Electron Neutrino */ mu_bar = -mu, /*!< Anti-Muon */ nu_mu_bar = -nu_mu, /*!< Anti-Muon Neutrino */ tau_bar = -tau, /*!< Anti-Tau */ nu_tau_bar = -nu_tau, /*!< Anti-Tau Neutrino */ gluon = 21, /*!< Gluon */ g = gluon, /*!< Gluon */ photon = 22, /*!< Photon */ gamma = photon, /*!< Photon */ Z = 23, /*!< Z Boson */ Wp = 24, /*!< W- Boson */ Wm = -Wp, /*!< W+ Boson */ h = 25, /*!< Higgs Boson */ Higgs = h, /*!< Higgs Boson */ higgs = h, /*!< Higgs Boson */ p = 2212, /*!< Proton */ proton = p, /*!< Proton */ p_bar = -p, /*!< Anti-Proton */ }; } using ParticleID = pid::ParticleID; //! Convert a particle name to the corresponding PDG particle ID ParticleID to_ParticleID(std::string const & name); /** * \brief Function to determine if particle is a parton * @param p PDG ID of particle * @returns true if the particle is a parton, false otherwise */ inline constexpr bool is_parton(ParticleID p){ return p == pid::gluon || std::abs(p) <= pid::top; } /** + * \brief Function to determine if particle is a quark + * @param id PDG ID of particle + * @returns true if the particle is a qaurk, false otherwise + */ + inline + constexpr bool is_quark(ParticleID id){ + return (id >= pid::down && id <= pid::top); + } + + /** + * \brief Function to determine if particle is a antiquark + * @param id PDG ID of particle + * @returns true if the particle is an antiquark, false otherwise + */ + inline + constexpr bool is_antiquark(ParticleID id){ + return (id <= pid::d_bar && id >= pid::t_bar); + } + + /** + * \brief Function to determine if particle is a (anti-)quark + * @param id PDG ID of particle + * @returns true if the particle is a quark or antiquark, false otherwise + */ + inline + constexpr bool is_anyquark(ParticleID id){ + return (id && id >= pid::t_bar && id <= pid::t); + } + + /** * \brief function to determine if the particle is a photon, W, Z, or Higgs boson * @param id PDG ID of particle * @returns true if the partice is a A,W,Z, or H, false otherwise */ inline constexpr bool is_AWZH_boson(ParticleID id){ return id == pid::Wm || (id >= pid::photon && id <= pid::Higgs); } } diff --git a/include/HEJ/Particle.hh b/include/HEJ/Particle.hh index c00890d..67af9db 100644 --- a/include/HEJ/Particle.hh +++ b/include/HEJ/Particle.hh @@ -1,125 +1,143 @@ /** * \file Particle.hh * \brief Contains the particle struct * * \authors Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie * \date 2019 * \copyright GPLv2 or later */ #pragma once #include #include "fastjet/PseudoJet.hh" #include "HEJ/optional.hh" #include "HEJ/PDG_codes.hh" namespace HEJ { using Colour = std::pair; //! Class representing a particle struct Particle { //! particle type ParticleID type; //! particle momentum fastjet::PseudoJet p; //! (optional) colour & anti-colour optional colour; //! get rapidity double rapidity() const{ return p.rapidity(); } //! get transverse momentum double perp() const{ return p.perp(); } //! get momentum in x direction double px() const{ return p.px(); } //! get momentum in y direction double py() const{ return p.py(); } //! get momentum in z direction double pz() const{ return p.pz(); } //! get energy double E() const{ return p.E(); } //! get mass double m() const{ return p.m(); } }; //! Functor to compare rapidities /** * This can be used whenever a rapidity comparison function is needed, * for example in many standard library functions. * * @see pz_less */ struct rapidity_less{ template bool operator()(FourVector const & p1, FourVector const & p2){ return p1.rapidity() < p2.rapidity(); } }; //! Functor to compare momenta in z direction /** * This can be used whenever a pz comparison function is needed, * for example in many standard library functions. * * @see rapidity_less */ struct pz_less{ template bool operator()(FourVector const & p1, FourVector const & p2){ return p1.pz() < p2.pz(); } }; //! Convert a vector of Particles to a vector of particle momenta inline std::vector to_PseudoJet( std::vector const & v ){ std::vector result; for(auto && sp: v) result.emplace_back(sp.p); return result; } //! Check if a particle is a parton, i.e. quark, antiquark, or gluon inline bool is_parton(Particle const & p){ return is_parton(p.type); } + //! Check if a particle is a quark + inline + bool is_quark(Particle const & p){ + return is_quark(p.type); + } + + //! Check if a particle is an anti-quark + inline + bool is_antiquark(Particle const & p){ + return is_antiquark(p.type); + } + + //! Check if a particle is a quark or anit-quark + inline + bool is_anyquark(Particle const & p){ + return is_anyquark(p.type); + } + //! Check if a particle is a photon, W, Z, or Higgs boson inline bool is_AWZH_boson(Particle const & particle){ return is_AWZH_boson(particle.type); } //! Extract all partons from a vector of particles inline std::vector filter_partons( std::vector const & v ){ std::vector result; result.reserve(v.size()); std::copy_if( begin(v), end(v), std::back_inserter(result), [](Particle const & p){ return is_parton(p); } ); return result; } }