| Summary: | rdecay02 produces negative weight in the root tree produced by the macro, u2380-b.mac | ||
|---|---|---|---|
| Product: | Examples/Extended | Reporter: | John Watts <john.w.watts> |
| Component: | radioactivedecay/exrdm | Assignee: | dennis.herbert.wright |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | dennis.herbert.wright |
| Priority: | P5 | ||
| Version: | 9.6 | ||
| Hardware: | All | ||
| OS: | Linux | ||
|
Description
John Watts
2013-06-14 21:24:37 CEST
Still working on this. Problem narrowed down to generalized application of Bateman equations. This is now fixed. The main problem was the accumulation of cancellation errors which are especially apparent in long decay chains. In the weight calculation there are sums of products of factors like tau1/(tau1 - tau2) which often alternate sign. Each term in these sums is then multiplied by factors of (1 - exp(...) ). The final result, which should always be positive, is sometimes a small negative number due to loss of precision. The main part of the solution is to use the C++11 function std::expm1 which is exp - 1. This function avoids the large cancellation errors which occur when using 1 - std::exp for arguments near zero. The result is that the magnitude of negative weights is reduced by around ten orders of magnitude, for example 1e-20 down to 1e-30. This is an indication that the decay chain math is correct and is attempting to produce a positive number, but that some small cancellation errors remain. In this case the code now sets negative values to zero since the error of doing so is quite small. The fix has been added to the Geant4 repository and will be available in the Geant4 10.5 beta release in June. |