diff --git a/FixedOrderGen/include/Unweighter.hh b/FixedOrderGen/include/Unweighter.hh index 5223e9d..de8d9b5 100644 --- a/FixedOrderGen/include/Unweighter.hh +++ b/FixedOrderGen/include/Unweighter.hh @@ -1,77 +1,75 @@ /** * \authors The HEJ collaboration (see AUTHORS for details) * \date 2019 * \copyright GPLv2 or later */ #pragma once -#include <limits> #include <cmath> #include "HEJ/optional.hh" #include "HEJ/RNG.hh" namespace HEJ { class Event; } namespace HEJFOG { namespace detail { bool has_jet_softer_than(HEJ::Event const & ev, double pt); template<typename Iterator> double calc_cut( Iterator begin, Iterator end, double max_dev, double min_pt ) { double mean = 0.; double err = 0.; double awt_sum = 0.; for(; begin != end; ++begin){ if(has_jet_softer_than(*begin, min_pt)) continue; const double awt = std::abs(begin->central().weight); const double tmp = awt*std::log(awt); mean += tmp; err += tmp*tmp; awt_sum += awt; } mean /= awt_sum; err = std::sqrt(err)/awt_sum; return std::exp(mean + max_dev*err); } } class Unweighter { public: template<typename Iterator> Unweighter( Iterator begin, Iterator end, double max_dev, HEJ::RNG & ran, /* minimum pt of jets for an event to be considered for unweighting * * If the 'jets: peak pt' option is set to the *resummation* jet * threshold, events with softer jets will have a spurious * large weight, although they hardly contribute after resummation. * This destroys the unweighting efficiency. * By setting min_unweight_pt to the same threshold, we can exclude * these events from unweighting. */ double min_unweight_pt = 0. ): cut_{detail::calc_cut(begin, end, max_dev, min_unweight_pt)}, min_unweight_pt_{min_unweight_pt}, ran_{ran} {} HEJ::optional<HEJ::Event> unweight(HEJ::Event ev) const; private: double cut_; double min_unweight_pt_; std::reference_wrapper<HEJ::RNG> ran_; - std::function<bool(HEJ::Event const &)> unweight_ok_; }; }