35 auto out = phi1 - phi2;
36 while (
out >= M_PI)
out -= 2 * M_PI;
37 while (
out < -M_PI)
out += 2 * M_PI;
43 template <
float (PHG4Hit::*accessor)(
int) const>
55 for (
const auto& hit : hits)
57 const double x0 = (hit->*accessor)(0);
58 const double x1 = (hit->*accessor)(1);
59 if (std::isnan(x0) || std::isnan(x1))
continue;
61 const double w = hit->get_edep();
65 const double r0 =
get_r(hit->get_x(0), hit->get_y(0));
66 const double r1 =
get_r(hit->get_x(1), hit->get_y(1));
72 swrx += w * (r0 * x0 + r1 * x1);
75 if (!valid)
return NAN;
77 const auto alpha = (sw * swrx - swr * swx);
78 const auto beta = (swr2 * swx - swr * swrx);
79 const auto denom = (sw * swr2 -
square(swr));
81 return (
alpha * rextrap + beta) / denom;