diff --git a/include/RHEJ/PDG_codes.hh b/include/RHEJ/PDG_codes.hh index b01c690..3c153e2 100644 --- a/include/RHEJ/PDG_codes.hh +++ b/include/RHEJ/PDG_codes.hh @@ -1,124 +1,133 @@ /** \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. */ #pragma once namespace RHEJ { //! 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 */ 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; /** * \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 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); } /** - * \brief Function to determine if particle is a parton - * @param p PDG ID of particle + * \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 p){ - return (p >= pid::down && p <= pid::top); + constexpr bool is_quark(ParticleID id){ + return (id >= pid::down && id <= pid::top); } /** - * \brief Function to determine if particle is a parton - * @param p PDG ID of particle + * \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 p){ - return (p <= pid::d_bar && p >= pid::t_bar); + 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 or Z * @param id PDG ID of particle * @returns true if the partice is a A,W,Z, or H, false otherwise */ inline constexpr bool is_AWZ_boson(ParticleID id){ return id == pid::Wm || (id >= pid::photon && id <= pid::Wp); } } diff --git a/include/RHEJ/utility.hh b/include/RHEJ/utility.hh index 4e44556..440af2f 100644 --- a/include/RHEJ/utility.hh +++ b/include/RHEJ/utility.hh @@ -1,215 +1,221 @@ /** * \file * \brief Contains various utilities */ #pragma once #include #include #include // FastJet Includes #include "fastjet/PseudoJet.hh" #include "fastjet/ClusterSequence.hh" #include "RHEJ/PDG_codes.hh" namespace RHEJ{ //! Class representing a particle struct Particle { //! particle type ParticleID type; //! particle momentum fastjet::PseudoJet p; //! 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 or Z boson inline bool is_AWZ_boson(Particle const & particle){ return is_AWZ_boson(particle.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; } //! Create a std::unique_ptr to a T object /** * For non-array types this works like std::make_unique, * which is not available under C++11 */ template std::unique_ptr make_unique(Args&&... a){ return std::unique_ptr{new T{std::forward(a)...}}; } //! Create an array containing the passed arguments template constexpr std::array make_array(T t, U&&... rest){ return {{t, std::forward(rest)...}}; } inline std::string join( std::string const & /* delim */, std::string const & str ){ return str; } //! Join strings with a delimiter /** * @param delim Delimiter to be put between consecutive strings * @param first First string * @param second Second string * @param rest Remaining strings */ template std::string join( std::string const & delim, std::string const & first, std::string const & second, Strings&&... rest ){ return join(delim, first + delim + second, std::forward(rest)...); } //! Return the name of the argument's type template std::string type_string(T&&){ return boost::core::demangle(typeid(T).name()); } //! Eliminate compiler warnings for unused variables template constexpr void ignore(T&&...) {} //! Check whether two doubles are closer than ep > 0 to each other inline bool nearby_ep(double a, double b, double ep){ assert(ep > 0); return std::abs(a-b) < ep; } //! Check whether all components of two PseudoJets are closer than ep to each other inline bool nearby_ep( fastjet::PseudoJet const & pa, fastjet::PseudoJet const & pb, double ep ){ assert(ep > 0); for(size_t i = 0; i < 4; ++i){ if(!nearby_ep(pa[i], pb[i], ep)) return false; } return true; } inline bool nearby( fastjet::PseudoJet const & pa, fastjet::PseudoJet const & pb, double const norm = 1. ){ return nearby_ep(pa, pb, 1e-7*norm); } }