diff --git a/include/HEJ/PDF.hh b/include/HEJ/PDF.hh index adbc025..44a09b2 100644 --- a/include/HEJ/PDF.hh +++ b/include/HEJ/PDF.hh @@ -1,81 +1,81 @@ /** \file * * \brief Contains all the necessary classes and functions for interaction with PDFs. * * \authors The HEJ collaboration (see AUTHORS for details) * \date 2019-2020 * \copyright GPLv2 or later */ #pragma once #include #include #include #include "HEJ/PDG_codes.hh" namespace LHAPDF { class PDF; } namespace HEJ { //! Class for interaction with a PDF set class PDF { public: /** * \brief PDF Constructor * @param id Particle ID according to PDG * @param beam1 Particle ID of particle in beam 1 * @param beam2 Particle ID of particle in beam 2 */ PDF(int id, ParticleID beam1, ParticleID beam2); /** * \brief Calculate the pdf value x*f(x, q) * @param beam_idx Beam number (0 or 1) * @param x Momentum fraction * @param q Energy scale * @param id PDG particle id * @returns x*f(x, q) * * Returns 0 if x or q are outside the range covered by the PDF set */ double pdfpt(std::size_t beam_idx, double x, double q, ParticleID id) const; /** * \brief Value of the strong coupling \f$\alpha_s(q)\f$ at the given scale * @param q Renormalisation scale * @returns Value of the strong coupling constant */ double Halphas(double q) const; //! Check if the energy scale is within the range covered by the PDF set /** * @param q Energy Scale * @returns true if q is within the covered range, false otherwise */ bool inRangeQ(double q) const; //! Check if the momentum fraction is within the range covered by the PDF set /** * @param x Momentum Fraction * @returns true if x is within the covered range, false otherwise */ bool inRangeX(double x) const; //! PDF id of the current set int id() const; PDF(PDF const & other) = delete; //!< Copy not possible PDF & operator=(PDF const & other) = delete; //!< Copy not possible - PDF(PDF && other) = default; //!< Moving allowed - PDF & operator=(PDF && other) = default; //!< Moving allowed + PDF(PDF && other); //!< Moving allowed + PDF & operator=(PDF && other); //!< Moving allowed ~PDF(); private: //! @internal unique_ptr does not allow copy std::unique_ptr pdf_; std::array beamtype_; }; } // namespace HEJ diff --git a/src/PDF.cc b/src/PDF.cc index f30a540..4cdd837 100644 --- a/src/PDF.cc +++ b/src/PDF.cc @@ -1,74 +1,76 @@ /** * \authors The HEJ collaboration (see AUTHORS for details) * \date 2019-2020 * \copyright GPLv2 or later */ #include "HEJ/PDF.hh" #include #include #include #include #include #include "LHAPDF/LHAPDF.h" namespace HEJ { namespace { int to_beam(ParticleID id){ if(std::abs(id) == pid::proton){ return (id > 0)?1:-1; } throw std::invalid_argument( "unknown beam type: " + std::to_string(id) ); } } // namespace PDF::PDF(int id, ParticleID beam1, ParticleID beam2): pdf_{LHAPDF::mkPDF(id)}, beamtype_{{to_beam(beam1), to_beam(beam2)}} {} double PDF::pdfpt(size_t beam_idx, double x, double q, ParticleID id) const{ if(!(inRangeQ(q) && inRangeX(x))) return 0.; if(id == pid::gluon){ return pdf_->xfxQ(pid::gluon,x,q); } if(std::abs(id) <= pid::top){ return pdf_->xfxQ(id*beamtype_[beam_idx],x,q); } std::cerr << "particle type unknown: "<< id << std::endl; return 0.0; } double PDF::Halphas(double q) const{ double as = pdf_->alphasQ(q); if (std::isnan(as) || as > 0.5) { as = 0.5; } return as; } int PDF::id() const{ return pdf_->lhapdfID(); } bool PDF::inRangeQ(double q) const{ return pdf_->inRangeQ(q); } bool PDF::inRangeX(double x) const{ return pdf_->inRangeX(x); } // can't be in header since we forward declare LHAPDF::PDF PDF::~PDF() = default; + PDF::PDF(PDF && other) = default; + PDF & PDF::operator=(PDF && other) = default; } // namespace HEJ