11#include <Math/Vector3D.h>
34 if (std::abs(x) < 4503599627370496.0) {
36 long n =
static_cast<long>(std::abs(x));
40 return std::lround(x);
51 inline double unfold(
double x,
int nx,
double A)
53 if (nx % 2 == 0)
return (nx * A + x);
54 else return (nx * A - x);
64 inline double unfold(
double kx,
int nx)
66 if (nx % 2 == 0)
return kx;
79 inline void fold(
double xu,
double A,
double& x,
double& kx,
int& nx)
98 inline double clip(
double x,
int Nx,
double A,
double xmi,
double xma)
101 x = std::max(std::min(x, xma), xmi) - Nx * A;
102 if (Nx % 2 != 0) x = -x;
114 return (j2 - j1 + 1 - std::abs(j1) % 2) / 2;
124 angle = fmod(angle, 2 * M_PI);
125 if (angle < 0) angle += 2 * M_PI;
134 inline void rotateUz(ROOT::Math::XYZVector& vec,
const ROOT::Math::XYZVector& z_Axis)
136 auto zAxis = z_Axis.Unit();
137 double cth = zAxis.Z();
138 double sth =
sqrt(1 - cth * cth);
140 if (cth < 0) vec = -vec;
143 double cfi = zAxis.X() / sth;
144 double sfi = zAxis.Y() / sth;
146 double x = cth * vec.X() + sth * vec.Z();
148 double z = -sth * vec.X() + cth * vec.Z();
149 vec.SetX(cfi * x - sfi * y);
150 vec.SetY(sfi * x + cfi * y);
double sqrt(double a)
sqrt for double
double unfold(double x, int nx, double A)
unfold a coordinate.
void rotateUz(ROOT::Math::XYZVector &vec, const ROOT::Math::XYZVector &z_Axis)
Replacement for a function TVector3::RotateUz which is not implemented in GenVector classes.
double clip(double x, int Nx, double A, double xmi, double xma)
Performs a clip on x w.r.t xmi and xma.
int getNumOfEven(int j1, int j2)
Returns number of even numbers in the range given by arguments.
void fold(double xu, double A, double &x, double &kx, int &nx)
fold a coordinate (inverse of unfold).
double within2PI(double angle)
Returns angle within 0 and 2PI.
long lround(double x)
Rounds to the nearest integer, halfway cases away from zero.
Abstract base class for different kinds of events.