PluginElements: particles not recorded when element crosses (or close to) origin
Summary
Noticed by @nesteruk_k: Particles are not recorded in some Probes. Likely the other PluginElements are affected too.
Steps to reproduce
A Probe crossing the origin, e.g. one defined as:
P: Probe, XSTART=-1e10, YSTART=0, XEND=1e10, YEND=0;
will not record any particles.
What is the expected correct behavior?
Recorded particle and output files: P.hist, P.h5, P.peaks
Possible fixes
A check is performed if the bunch is close to the probe (and only then individual particles are checked) as follows:
https://gitlab.psi.ch/OPAL/src/blob/master/src/Classic/AbsBeamline/Probe.cpp#L62
if( rbunch_max > rstart_m - 10.0 && rbunch_min < rend_m + 10.0 ) {
With rstart_m
and rend_m
defined as:
https://gitlab.psi.ch/OPAL/src/blob/master/src/Classic/AbsBeamline/PluginElement.cpp#L86
rstart_m = std::hypot(xstart, ystart);
rend_m = std::hypot(xend, yend);
// start position is the one with lowest radius
if (rstart_m > rend_m) {
std::swap(xstart_m, xend_m);
std::swap(ystart_m, yend_m);
std::swap(rstart_m, rend_m);
}
Instead of rstart_m
the closest point to the origin should be used in the check.