Skip to content

Commit

Permalink
Prevent Nan-weights from being accumulated
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Apr 6, 2017
1 parent 002e67c commit 60ba176
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
New in 0.5:
===========

- fixed a bug that caused NaNs to slip through to the integrated result if they
were coming from the point's weight
- 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
Expand Down
30 changes: 16 additions & 14 deletions include/hep/mc/internal/accumulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ class accumulator<T, true>
// are generated here
T value = integrand.function()(point, projector);

if (std::isfinite(value))
if (value != T())
{
if (value != T())
value *= point.weight();

if (std::isfinite(value))
{
value *= point.weight();
accumulate(sums_[0], sums_[1], compensations_[0], value);
}
}
else
{
value = T();
else
{
value = T();
}
}

return value;
Expand Down Expand Up @@ -198,17 +199,18 @@ class accumulator<T, false>
// are generated here
T value = integrand.function()(point);

if (std::isfinite(value))
if (value != T())
{
if (value != T())
value *= point.weight();

if (std::isfinite(value))
{
value *= point.weight();
accumulate(sums_[0], sums_[1], sums_[2], value);
}
}
else
{
value = T();
else
{
value = T();
}
}

return value;
Expand Down

0 comments on commit 60ba176

Please sign in to comment.