diff --git a/include/HEJ/Particle.hh b/include/HEJ/Particle.hh index 67af9db..5b287a1 100644 --- a/include/HEJ/Particle.hh +++ b/include/HEJ/Particle.hh @@ -1,143 +1,144 @@ /** * \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 + //! @TODO resolve compiler warnings of "missing initializer for member" 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; } }