From 002e67c5e699df53539feda271ea643139208892 Mon Sep 17 00:00:00 2001 From: Christopher Schwan Date: Wed, 22 Feb 2017 19:40:40 +0100 Subject: [PATCH] Add possibility to disable channels --- NEWS.rst | 1 + include/hep/mc/multi_channel.hpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 71e7a5e..d613e86 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,6 +1,7 @@ New in 0.5: =========== +- it is now possible to disable channels by setting their weight to zero - the function ``multi_channel_verbose_callback`` now prints an overview of the smallest and largest a-priori weights - the functions ``multi_channel`` and ``mpi_multi_channel`` now accept an diff --git a/include/hep/mc/multi_channel.hpp b/include/hep/mc/multi_channel.hpp index f6e6e9d..b6c9edc 100644 --- a/include/hep/mc/multi_channel.hpp +++ b/include/hep/mc/multi_channel.hpp @@ -72,6 +72,13 @@ inline std::vector multi_channel_refine_weights( for (T& weight : new_weights) { + if (weight == T()) + { + // do not enable disabled channels (with weight zero) by setting + // them to the minimum weight + continue; + } + weight /= sum_of_new_weights; weight = std::fmax(weight, minimum_weight); new_sum += weight;