diff --git a/include/HEJ/Parameters.hh b/include/HEJ/Parameters.hh index e67b1ae..b9ed559 100644 --- a/include/HEJ/Parameters.hh +++ b/include/HEJ/Parameters.hh @@ -1,172 +1,155 @@ /** \file * \brief Containers for Parameter variations, e.g. different Weights * * \authors Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie * \date 2019 * \copyright GPLv2 or later */ #pragma once #include #include #include "HEJ/exceptions.hh" namespace HEJ{ //! Collection of parameters, e.g. Weights, assigned to a single event /** * A number of member functions of the MatrixElement class return Parameters * objects containing the squares of the matrix elements for the various * scale choices. */ template struct Parameters { T central; std::vector variations; template Parameters& operator*=(Parameters const & other); Parameters& operator*=(double factor); template Parameters& operator/=(Parameters const & other); Parameters& operator/=(double factor); }; template inline Parameters operator*(Parameters a, Parameters const & b) { a*=b; return a; } template inline Parameters operator*(Parameters a, double b) { a*=b; return a; } template inline Parameters operator*(double b, Parameters a) { a*=b; return a; } template inline Parameters operator/(Parameters a, Parameters const & b) { a/=b; return a; } template inline Parameters operator/(Parameters a, double b) { a/=b; return a; } //! Alias for weight container, e.g. used by the MatrixElement using Weights = Parameters; //! Description of event parameters, see also EventParameters struct ParameterDescription { //! Name of central scale choice (e.g. "H_T/2") std::string scale_name; //! Actual renormalisation scale divided by central scale double mur_factor; //! Actual factorisation scale divided by central scale double muf_factor; ParameterDescription() = default; ParameterDescription( std::string scale_name, double mur_factor, double muf_factor ): scale_name{scale_name}, mur_factor{mur_factor}, muf_factor{muf_factor} {}; }; //! Event parameters struct EventParameters{ double mur; /**< Value of the Renormalisation Scale */ double muf; /**< Value of the Factorisation Scale */ double weight; /**< Event Weight */ //! Optional description std::shared_ptr description = nullptr; //! multiply weight by factor EventParameters& operator*=(double factor){ weight*=factor; return *this; }; //! divide weight by factor EventParameters& operator/=(double factor){ weight/=factor; return *this; }; - // @TODO: Explain. Consistency with what? Why not just delete? - //! DO NOT USE. This is only for consistency. - EventParameters& operator*=(EventParameters const &){ - throw not_implemented("Can not multiple two EventParameters"); - }; - //! DO NOT USE. This is only for consistency. - EventParameters& operator/=(EventParameters const &){ - throw not_implemented("Can not divide two EventParameters"); - }; }; - inline EventParameters operator*(EventParameters a, EventParameters const & b){ - a*=b; - return a; - } inline EventParameters operator*(EventParameters a, double b){ a*=b; return a; } inline EventParameters operator*(double b, EventParameters a){ a*=b; return a; } - inline EventParameters operator/(EventParameters a, EventParameters const & b){ - a/=b; - return a; - } inline EventParameters operator/(EventParameters a, double b){ a/=b; return a; } //! @{ //! @internal Implementation of template functions template template Parameters& Parameters::operator*=(Parameters const & other) { if(other.variations.size() != variations.size()) { throw std::invalid_argument{"Wrong number of Parameters"}; } central *= other.central; for(std::size_t i = 0; i < variations.size(); ++i) { variations[i] *= other.variations[i]; } return *this; }; template Parameters& Parameters::operator*=(double factor) { central *= factor; for(auto & wt: variations) wt *= factor; return *this; }; template template Parameters& Parameters::operator/=(Parameters const & other) { if(other.variations.size() != variations.size()) { throw std::invalid_argument{"Wrong number of Parameters"}; } central /= other.central; for(std::size_t i = 0; i < variations.size(); ++i) { variations[i] /= other.variations[i]; } return *this; }; template Parameters& Parameters::operator/=(double factor) { central /= factor; for(auto & wt: variations) wt /= factor; return *this; }; //! @} }